Commit 351dc041 authored by Samesh Buddhika Alahakoon's avatar Samesh Buddhika Alahakoon

Merge branch 'IT18109672' into 'master'

It18109672

See merge request !36
parents 23463232 6414e808
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@drawable/icon"
android:label="@string/app_name" android:label="@string/app_name"
android:requestLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
......
...@@ -21,11 +21,13 @@ import com.app.smartphotoeditor.adapters.FilterAdapter; ...@@ -21,11 +21,13 @@ import com.app.smartphotoeditor.adapters.FilterAdapter;
import com.app.smartphotoeditor.config.ImageList; import com.app.smartphotoeditor.config.ImageList;
import com.app.smartphotoeditor.listeners.OnBitmapChanged; import com.app.smartphotoeditor.listeners.OnBitmapChanged;
import com.app.smartphotoeditor.listeners.OnCameraPreviewChanged; import com.app.smartphotoeditor.listeners.OnCameraPreviewChanged;
import com.app.smartphotoeditor.listeners.OnVoiceCommandResultChanged;
import com.app.smartphotoeditor.listeners.ml.OnEyeStatusChanged; import com.app.smartphotoeditor.listeners.ml.OnEyeStatusChanged;
import com.app.smartphotoeditor.listeners.ml.OnGestureDetected; import com.app.smartphotoeditor.listeners.ml.OnGestureDetected;
import com.app.smartphotoeditor.sdk.Methods; import com.app.smartphotoeditor.sdk.Methods;
import com.app.smartphotoeditor.sdk.RealTimeCamera; import com.app.smartphotoeditor.sdk.RealTimeCamera;
import com.app.smartphotoeditor.services.ComputerVision; import com.app.smartphotoeditor.services.ComputerVision;
import com.app.smartphotoeditor.services.SpeechService;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.warkiz.tickseekbar.OnSeekChangeListener; import com.warkiz.tickseekbar.OnSeekChangeListener;
import com.warkiz.tickseekbar.SeekParams; import com.warkiz.tickseekbar.SeekParams;
...@@ -47,7 +49,7 @@ import java.util.List; ...@@ -47,7 +49,7 @@ import java.util.List;
public class AddEffects extends AppCompatActivity public class AddEffects extends AppCompatActivity
implements OnBitmapChanged, implements OnBitmapChanged,
OnGestureDetected,OnEyeStatusChanged{ OnGestureDetected,OnEyeStatusChanged, OnVoiceCommandResultChanged {
static static
{ {
...@@ -66,7 +68,6 @@ public class AddEffects extends AppCompatActivity ...@@ -66,7 +68,6 @@ public class AddEffects extends AppCompatActivity
private TickSeekBar listener,listener2,listener3; private TickSeekBar listener,listener2,listener3;
private Bitmap subFilterBitmap = null; private Bitmap subFilterBitmap = null;
private boolean isAnEffectAdded = false;
private boolean isAllowedToChangeFilters = true; private boolean isAllowedToChangeFilters = true;
...@@ -77,38 +78,35 @@ public class AddEffects extends AppCompatActivity ...@@ -77,38 +78,35 @@ public class AddEffects extends AppCompatActivity
private ComputerVision computerVision; private ComputerVision computerVision;
int count = 0;
int count2 = 0;
boolean isPossible = true;
private SpeechService speechService;
@Override @Override
protected void onDestroy() protected void onResume() {
{ super.onResume();
super.onDestroy(); speechService.onResume();
} }
@Override @Override
public void onBackPressed() protected void onPause() {
{ super.onPause();
speechService.onPause();
}
if(subFiltersLayout.getVisibility() == View.VISIBLE)
{
subFiltersLayout.setVisibility(View.GONE);
}
else
{
super.onBackPressed();
}
@Override
protected void onStop() {
super.onStop();
speechService.onStop();
}
@Override
protected void onDestroy()
{
super.onDestroy();
} }
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -137,6 +135,8 @@ public class AddEffects extends AppCompatActivity ...@@ -137,6 +135,8 @@ public class AddEffects extends AppCompatActivity
init(); init();
setData(); setData();
speechService = new SpeechService(getApplicationContext(),findViewById(R.id.progress),this);
} }
private void setPreviewFrame(Mat previewMat) private void setPreviewFrame(Mat previewMat)
{ {
...@@ -281,7 +281,6 @@ public class AddEffects extends AppCompatActivity ...@@ -281,7 +281,6 @@ public class AddEffects extends AppCompatActivity
Glide.with(getApplicationContext()).load(subFilterBitmap).into(userSelectedImage); Glide.with(getApplicationContext()).load(subFilterBitmap).into(userSelectedImage);
isAnEffectAdded = true;
} }
...@@ -293,7 +292,6 @@ public class AddEffects extends AppCompatActivity ...@@ -293,7 +292,6 @@ public class AddEffects extends AppCompatActivity
listener2.setProgress(0); listener2.setProgress(0);
listener3.setProgress(0); listener3.setProgress(0);
subFilterBitmap = null; subFilterBitmap = null;
isAnEffectAdded = true;
currentEditingBitmap = bitmap; currentEditingBitmap = bitmap;
...@@ -322,7 +320,13 @@ public class AddEffects extends AppCompatActivity ...@@ -322,7 +320,13 @@ public class AddEffects extends AppCompatActivity
void findViewPoint(int x,int y) void findViewPoint(int x,int y)
{ {
ImageView cursor = findViewById(R.id.cursor);
int viewMaxX = 0;
int viewMaxY = 0; int viewMaxY = 0;
for(View view : viewsInDisplay) for(View view : viewsInDisplay)
{ {
int[] location = new int[2]; int[] location = new int[2];
...@@ -331,6 +335,10 @@ public class AddEffects extends AppCompatActivity ...@@ -331,6 +335,10 @@ public class AddEffects extends AppCompatActivity
int viewX = location[0] + (view.getWidth() / 2); int viewX = location[0] + (view.getWidth() / 2);
int viewY = location[1] / 2; int viewY = location[1] / 2;
if(viewX >= viewMaxX)
{
viewMaxX = viewX;
}
if(viewY >= viewMaxY) if(viewY >= viewMaxY)
{ {
viewMaxY = viewY; viewMaxY = viewY;
...@@ -338,130 +346,50 @@ public class AddEffects extends AppCompatActivity ...@@ -338,130 +346,50 @@ public class AddEffects extends AppCompatActivity
} }
if(x > viewMaxX)
ImageView b = findViewById(R.id.cursor);
if(x == 620 || x == 720 || x == 360)
{ {
viewsInDisplay.get(1).setBackgroundColor(Color.RED); x = viewMaxX;
viewsInDisplay.get(0).setBackgroundColor(Color.BLACK);
} }
else if(y > viewMaxY)
{ {
viewsInDisplay.get(0).setBackgroundColor(Color.RED); y = viewMaxY;
viewsInDisplay.get(1).setBackgroundColor(Color.BLACK);
} }
b.animate().x(x);
b.animate().y(viewMaxY); for(View view : viewsInDisplay)
{
int[] location = new int[2];
Log.d("XXXXXX","x-" + x); view.getLocationOnScreen(location);
// ImageView b = findViewById(R.id.cursor);
// int viewX = location[0];
// int viewY = location[1];
// int viewMaxX = 0;
// int viewMaxY = 0;
// int viewMaxWidth = viewX + view.getWidth();
// int viewMinWidth = viewX - view.getWidth();
//
// for(View view : viewsInDisplay) int viewMaxHeight = viewY + view.getHeight();
// { int viewMinHeight = viewY - view.getHeight();
// int[] location = new int[2];
// view.getLocationOnScreen(location);
// if ((x >= viewMinWidth && x <= viewMaxWidth))
// int viewX = location[0] + (view.getWidth() / 2); {
// int viewY = location[1] / 2;
// view.setBackgroundColor(Color.RED);
// if(viewX >= viewMaxX)
// { cursor.animate().x((viewMinWidth + viewMaxWidth) / 2);
// viewMaxX = viewX; cursor.animate().y((viewMinHeight + viewMaxHeight) / 2);
// }
// if(viewY >= viewMaxY) }
// { else
// viewMaxY = viewY; {
// } view.setBackgroundColor(Color.BLACK);
// }
// }
// }
// if(x > viewMaxX) cursor.animate().x(x);
// { cursor.animate().y(y);
// x = viewMaxX;
// }
// if(y > viewMaxY)
// {
// y = viewMaxY;
// }
//
//
//
//
//
//
//
//
// for(View view : viewsInDisplay)
// {
// int[] location = new int[2];
// view.getLocationOnScreen(location);
//
// int viewX = location[0];
// int viewY = location[1];
//
//
// int viewMaxWidth = viewX + view.getWidth();
// int viewMinWidth = viewX - view.getWidth();
//
// int viewMaxHeight = viewY + view.getHeight();
// int viewMinHeight = viewY - view.getHeight();
//
//
// if ((x >= viewMinWidth && x <= viewMaxWidth))
// {
//
// if(lastLookedView != null && lastLookedView.getId() == view.getId())
// {
// count++;
// if(count >= 3)
// {
// //lock for some seconds
// isPossible = false;
// }
// if(count >= 10)
// {
// count = 0;
// isPossible = true;
// lastLookedView = null;
// }
// }
// else
// {
// count = 0;
// }
//
// if(isPossible)
// {
// view.setBackgroundColor(Color.RED);
// b.animate().x((viewMinWidth + viewMaxWidth) / 2);
// b.animate().y((viewMinHeight + viewMaxHeight) / 2);
// lastLookedView = view;
// }
// else
// {
// lastLookedView.setBackgroundColor(Color.RED);
// }
//
//
// }
// else
// {
// view.setBackgroundColor(Color.BLACK);
// }
//
// }
// b.animate().x(x);
// b.animate().y(y);
} }
@Override @Override
...@@ -482,26 +410,6 @@ public class AddEffects extends AppCompatActivity ...@@ -482,26 +410,6 @@ public class AddEffects extends AppCompatActivity
@Override @Override
public void onPupilChanged(Mat binary,int x, int y,int range,int pupilX) public void onPupilChanged(Mat binary,int x, int y,int range,int pupilX)
{ {
// try
// {
// Methods.saveImage(getApplicationContext(),Methods.matToBit(binary),"Right");
// }
// catch (IOException e)
// {
// e.printStackTrace();
// }
runOnUiThread(new Runnable()
{
@Override
public void run()
{
//setPreviewFrame(binary);
ProgressBar bar = findViewById(R.id.progress);
bar.setMax(range);
bar.setProgress(pupilX);
}
});
findViewPoint(x,y); findViewPoint(x,y);
} }
...@@ -559,9 +467,11 @@ public class AddEffects extends AppCompatActivity ...@@ -559,9 +467,11 @@ public class AddEffects extends AppCompatActivity
public void Save(View view) public void Save(View view)
{ {
ImageList.getInstance().addBitmap(currentEditingBitmap,true); if(currentEditingBitmap != null)
{
ImageList.getInstance().addBitmap(currentEditingBitmap,true);
}
Back(null); Back(null);
} }
public void Back(View view) public void Back(View view)
...@@ -569,4 +479,36 @@ public class AddEffects extends AppCompatActivity ...@@ -569,4 +479,36 @@ public class AddEffects extends AppCompatActivity
setResult(100); setResult(100);
finish(); finish();
} }
@Override
public void back() {
Back(null);
}
@Override
public void exit() {
}
@Override
public void undo() {
}
@Override
public void redo() {
}
@Override
public void save() {
Save(null);
}
@Override
public void select() {
}
} }
...@@ -49,6 +49,7 @@ public class AdjustBrightness extends AppCompatActivity ...@@ -49,6 +49,7 @@ public class AdjustBrightness extends AppCompatActivity
private SpeechService speechService; private SpeechService speechService;
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
...@@ -74,7 +75,7 @@ public class AdjustBrightness extends AppCompatActivity ...@@ -74,7 +75,7 @@ public class AdjustBrightness extends AppCompatActivity
setContentView(R.layout.activity_adjust_brightness); setContentView(R.layout.activity_adjust_brightness);
viewsInDisplay.add(findViewById(R.id.back)); viewsInDisplay.add(findViewById(R.id.back));
viewsInDisplay.add(findViewById(R.id.save)); viewsInDisplay.add(findViewById(R.id.select_btn));
computerVision = new ComputerVision(this,this,this); computerVision = new ComputerVision(this,this,this);
...@@ -163,17 +164,10 @@ public class AdjustBrightness extends AppCompatActivity ...@@ -163,17 +164,10 @@ public class AdjustBrightness extends AppCompatActivity
} }
void findViewPoint(int x,int y) void findViewPoint(int x,int y)
{ {
ImageView cursor = findViewById(R.id.cursor);
//if(!isPossible) return;
ImageView b = findViewById(R.id.cursor);
int viewMaxX = 0; int viewMaxX = 0;
int viewMinX = 0;
int viewMaxY = 0; int viewMaxY = 0;
int viewMinY = 0;
...@@ -206,23 +200,6 @@ public class AdjustBrightness extends AppCompatActivity ...@@ -206,23 +200,6 @@ public class AdjustBrightness extends AppCompatActivity
} }
//
// b.animate().x(x);
// b.animate().y(y);
for(View view : viewsInDisplay) for(View view : viewsInDisplay)
{ {
int[] location = new int[2]; int[] location = new int[2];
...@@ -231,16 +208,6 @@ public class AdjustBrightness extends AppCompatActivity ...@@ -231,16 +208,6 @@ public class AdjustBrightness extends AppCompatActivity
int viewX = location[0]; int viewX = location[0];
int viewY = location[1]; int viewY = location[1];
// if(viewX >= viewMaxX)
// {
// viewMaxX = viewX;
// }
// if(viewY >= viewMaxY)
// {
// viewMaxY = viewY;
// }
Log.d("aaaaaaaaaaaa", "View=" + view.getId() + "X=" + viewX + ", Y=" + viewY);
int viewMaxWidth = viewX + view.getWidth(); int viewMaxWidth = viewX + view.getWidth();
int viewMinWidth = viewX - view.getWidth(); int viewMinWidth = viewX - view.getWidth();
...@@ -248,40 +215,14 @@ public class AdjustBrightness extends AppCompatActivity ...@@ -248,40 +215,14 @@ public class AdjustBrightness extends AppCompatActivity
int viewMaxHeight = viewY + view.getHeight(); int viewMaxHeight = viewY + view.getHeight();
int viewMinHeight = viewY - view.getHeight(); int viewMinHeight = viewY - view.getHeight();
//b.animate().y((viewMinHeight + viewMaxHeight) / 2);
if ((x >= viewMinWidth && x <= viewMaxWidth)) if ((x >= viewMinWidth && x <= viewMaxWidth))
{ {
if(lastLookedView != null && lastLookedView.getId() == view.getId())
{
count++;
}
else
{
count = 0;
}
if(count >= 3)
{
isPossible = false;
checkCount();
}
view.setBackgroundColor(Color.RED); view.setBackgroundColor(Color.RED);
cursor.animate().x((viewMinWidth + viewMaxWidth) / 2);
cursor.animate().y((viewMinHeight + viewMaxHeight) / 2);
b.animate().x((viewMinWidth + viewMaxWidth) / 2);
b.animate().y((viewMinHeight + viewMaxHeight) / 2);
Log.d("bbbbb", "Came here");
lastLookedView = view;
} }
else else
...@@ -290,8 +231,8 @@ public class AdjustBrightness extends AppCompatActivity ...@@ -290,8 +231,8 @@ public class AdjustBrightness extends AppCompatActivity
} }
} }
b.animate().x(x); cursor.animate().x(x);
b.animate().y(y); cursor.animate().y(y);
} }
private void checkCount() private void checkCount()
......
...@@ -76,7 +76,7 @@ public class AdjustSaturation extends AppCompatActivity ...@@ -76,7 +76,7 @@ public class AdjustSaturation extends AppCompatActivity
viewsInDisplay.add(findViewById(R.id.back)); viewsInDisplay.add(findViewById(R.id.back));
viewsInDisplay.add(findViewById(R.id.save)); viewsInDisplay.add(findViewById(R.id.select_btn));
computerVision = new ComputerVision(this,this,this); computerVision = new ComputerVision(this,this,this);
...@@ -101,7 +101,7 @@ public class AdjustSaturation extends AppCompatActivity ...@@ -101,7 +101,7 @@ public class AdjustSaturation extends AppCompatActivity
@Override @Override
public void onSeeking(SeekParams seekParams) public void onSeeking(SeekParams seekParams)
{ {
saturationLevel = seekBar.getProgress() / 10; saturationLevel = seekBar.getProgress() / 40;
createImage(); createImage();
} }
@Override @Override
...@@ -161,17 +161,10 @@ public class AdjustSaturation extends AppCompatActivity ...@@ -161,17 +161,10 @@ public class AdjustSaturation extends AppCompatActivity
} }
void findViewPoint(int x,int y) void findViewPoint(int x,int y)
{ {
ImageView cursor = findViewById(R.id.cursor);
//if(!isPossible) return;
ImageView b = findViewById(R.id.cursor);
int viewMaxX = 0; int viewMaxX = 0;
int viewMinX = 0;
int viewMaxY = 0; int viewMaxY = 0;
int viewMinY = 0;
...@@ -204,23 +197,6 @@ public class AdjustSaturation extends AppCompatActivity ...@@ -204,23 +197,6 @@ public class AdjustSaturation extends AppCompatActivity
} }
//
// b.animate().x(x);
// b.animate().y(y);
for(View view : viewsInDisplay) for(View view : viewsInDisplay)
{ {
int[] location = new int[2]; int[] location = new int[2];
...@@ -229,16 +205,6 @@ public class AdjustSaturation extends AppCompatActivity ...@@ -229,16 +205,6 @@ public class AdjustSaturation extends AppCompatActivity
int viewX = location[0]; int viewX = location[0];
int viewY = location[1]; int viewY = location[1];
// if(viewX >= viewMaxX)
// {
// viewMaxX = viewX;
// }
// if(viewY >= viewMaxY)
// {
// viewMaxY = viewY;
// }
Log.d("aaaaaaaaaaaa", "View=" + view.getId() + "X=" + viewX + ", Y=" + viewY);
int viewMaxWidth = viewX + view.getWidth(); int viewMaxWidth = viewX + view.getWidth();
int viewMinWidth = viewX - view.getWidth(); int viewMinWidth = viewX - view.getWidth();
...@@ -246,40 +212,14 @@ public class AdjustSaturation extends AppCompatActivity ...@@ -246,40 +212,14 @@ public class AdjustSaturation extends AppCompatActivity
int viewMaxHeight = viewY + view.getHeight(); int viewMaxHeight = viewY + view.getHeight();
int viewMinHeight = viewY - view.getHeight(); int viewMinHeight = viewY - view.getHeight();
//b.animate().y((viewMinHeight + viewMaxHeight) / 2);
if ((x >= viewMinWidth && x <= viewMaxWidth)) if ((x >= viewMinWidth && x <= viewMaxWidth))
{ {
if(lastLookedView != null && lastLookedView.getId() == view.getId())
{
count++;
}
else
{
count = 0;
}
if(count >= 3)
{
isPossible = false;
checkCount();
}
view.setBackgroundColor(Color.RED); view.setBackgroundColor(Color.RED);
cursor.animate().x((viewMinWidth + viewMaxWidth) / 2);
cursor.animate().y((viewMinHeight + viewMaxHeight) / 2);
b.animate().x((viewMinWidth + viewMaxWidth) / 2);
b.animate().y((viewMinHeight + viewMaxHeight) / 2);
Log.d("bbbbb", "Came here");
lastLookedView = view;
} }
else else
...@@ -288,8 +228,8 @@ public class AdjustSaturation extends AppCompatActivity ...@@ -288,8 +228,8 @@ public class AdjustSaturation extends AppCompatActivity
} }
} }
b.animate().x(x); cursor.animate().x(x);
b.animate().y(y); cursor.animate().y(y);
} }
private void checkCount() private void checkCount()
{ {
......
...@@ -102,7 +102,7 @@ public class DenoisingActivity extends AppCompatActivity ...@@ -102,7 +102,7 @@ public class DenoisingActivity extends AppCompatActivity
viewsInDisplay.add(findViewById(R.id.back)); viewsInDisplay.add(findViewById(R.id.back));
viewsInDisplay.add(findViewById(R.id.save)); viewsInDisplay.add(findViewById(R.id.select_btn));
computerVision = new ComputerVision(this,this,this); computerVision = new ComputerVision(this,this,this);
...@@ -220,17 +220,10 @@ public class DenoisingActivity extends AppCompatActivity ...@@ -220,17 +220,10 @@ public class DenoisingActivity extends AppCompatActivity
} }
void findViewPoint(int x,int y) void findViewPoint(int x,int y)
{ {
ImageView cursor = findViewById(R.id.cursor);
//if(!isPossible) return;
ImageView b = findViewById(R.id.cursor);
int viewMaxX = 0; int viewMaxX = 0;
int viewMinX = 0;
int viewMaxY = 0; int viewMaxY = 0;
int viewMinY = 0;
...@@ -263,23 +256,6 @@ public class DenoisingActivity extends AppCompatActivity ...@@ -263,23 +256,6 @@ public class DenoisingActivity extends AppCompatActivity
} }
//
// b.animate().x(x);
// b.animate().y(y);
for(View view : viewsInDisplay) for(View view : viewsInDisplay)
{ {
int[] location = new int[2]; int[] location = new int[2];
...@@ -288,16 +264,6 @@ public class DenoisingActivity extends AppCompatActivity ...@@ -288,16 +264,6 @@ public class DenoisingActivity extends AppCompatActivity
int viewX = location[0]; int viewX = location[0];
int viewY = location[1]; int viewY = location[1];
// if(viewX >= viewMaxX)
// {
// viewMaxX = viewX;
// }
// if(viewY >= viewMaxY)
// {
// viewMaxY = viewY;
// }
Log.d("aaaaaaaaaaaa", "View=" + view.getId() + "X=" + viewX + ", Y=" + viewY);
int viewMaxWidth = viewX + view.getWidth(); int viewMaxWidth = viewX + view.getWidth();
int viewMinWidth = viewX - view.getWidth(); int viewMinWidth = viewX - view.getWidth();
...@@ -305,40 +271,14 @@ public class DenoisingActivity extends AppCompatActivity ...@@ -305,40 +271,14 @@ public class DenoisingActivity extends AppCompatActivity
int viewMaxHeight = viewY + view.getHeight(); int viewMaxHeight = viewY + view.getHeight();
int viewMinHeight = viewY - view.getHeight(); int viewMinHeight = viewY - view.getHeight();
//b.animate().y((viewMinHeight + viewMaxHeight) / 2);
if ((x >= viewMinWidth && x <= viewMaxWidth)) if ((x >= viewMinWidth && x <= viewMaxWidth))
{ {
if(lastLookedView != null && lastLookedView.getId() == view.getId())
{
count++;
}
else
{
count = 0;
}
if(count >= 3)
{
isPossible = false;
checkCount();
}
view.setBackgroundColor(Color.RED); view.setBackgroundColor(Color.RED);
cursor.animate().x((viewMinWidth + viewMaxWidth) / 2);
cursor.animate().y((viewMinHeight + viewMaxHeight) / 2);
b.animate().x((viewMinWidth + viewMaxWidth) / 2);
b.animate().y((viewMinHeight + viewMaxHeight) / 2);
Log.d("bbbbb", "Came here");
lastLookedView = view;
} }
else else
...@@ -347,23 +287,8 @@ public class DenoisingActivity extends AppCompatActivity ...@@ -347,23 +287,8 @@ public class DenoisingActivity extends AppCompatActivity
} }
} }
b.animate().x(x); cursor.animate().x(x);
b.animate().y(y); cursor.animate().y(y);
}
private void checkCount()
{
count++;
if(count >= 5)
{
isPossible = true;
count = 0;
}
else
{
isPossible = false;
}
} }
@Override @Override
......
...@@ -2,6 +2,7 @@ package com.app.smartphotoeditor.activities; ...@@ -2,6 +2,7 @@ package com.app.smartphotoeditor.activities;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
...@@ -30,6 +31,7 @@ import com.bumptech.glide.Glide; ...@@ -30,6 +31,7 @@ import com.bumptech.glide.Glide;
import org.opencv.core.Mat; import org.opencv.core.Mat;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
public class EditorActivity extends AppCompatActivity public class EditorActivity extends AppCompatActivity
...@@ -45,6 +47,8 @@ public class EditorActivity extends AppCompatActivity ...@@ -45,6 +47,8 @@ public class EditorActivity extends AppCompatActivity
private SpeechService speechService; private SpeechService speechService;
private ArrayList<View> viewsInDisplay = new ArrayList<>();
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data)
...@@ -78,6 +82,9 @@ public class EditorActivity extends AppCompatActivity ...@@ -78,6 +82,9 @@ public class EditorActivity extends AppCompatActivity
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_editor); setContentView(R.layout.activity_editor);
tools_rv = findViewById(R.id.tools_rv); tools_rv = findViewById(R.id.tools_rv);
toolsAdapter = new ToolsAdapter(getApplicationContext(), new OnToolClicked() { toolsAdapter = new ToolsAdapter(getApplicationContext(), new OnToolClicked() {
@Override @Override
...@@ -112,6 +119,8 @@ public class EditorActivity extends AppCompatActivity ...@@ -112,6 +119,8 @@ public class EditorActivity extends AppCompatActivity
tools_rv.setLayoutManager(layoutManager); tools_rv.setLayoutManager(layoutManager);
tools_rv.setAdapter(toolsAdapter); tools_rv.setAdapter(toolsAdapter);
computerVision = new ComputerVision(this,this,this); computerVision = new ComputerVision(this,this,this);
ConstraintLayout constraintLayout = findViewById(R.id.constraint_main); ConstraintLayout constraintLayout = findViewById(R.id.constraint_main);
...@@ -124,6 +133,9 @@ public class EditorActivity extends AppCompatActivity ...@@ -124,6 +133,9 @@ public class EditorActivity extends AppCompatActivity
} }
}).initialize(); }).initialize();
viewsInDisplay.add(findViewById(R.id.back));
viewsInDisplay.add(findViewById(R.id.select_btn));
methods = new Methods(getApplicationContext()); methods = new Methods(getApplicationContext());
...@@ -138,6 +150,7 @@ public class EditorActivity extends AppCompatActivity ...@@ -138,6 +150,7 @@ public class EditorActivity extends AppCompatActivity
speechService = new SpeechService(getApplicationContext(),findViewById(R.id.speech_progress),this); speechService = new SpeechService(getApplicationContext(),findViewById(R.id.speech_progress),this);
} }
private void setPreviewFrame(Mat previewMat) private void setPreviewFrame(Mat previewMat)
{ {
...@@ -218,6 +231,7 @@ public class EditorActivity extends AppCompatActivity ...@@ -218,6 +231,7 @@ public class EditorActivity extends AppCompatActivity
@Override @Override
public void onPupilChanged(Mat binary,int x, int y,int range, int pupilX) { public void onPupilChanged(Mat binary,int x, int y,int range, int pupilX) {
findViewPoint(x,y);
} }
@Override @Override
...@@ -354,4 +368,78 @@ public class EditorActivity extends AppCompatActivity ...@@ -354,4 +368,78 @@ public class EditorActivity extends AppCompatActivity
} }
}); });
} }
void findViewPoint(int x,int y)
{
ImageView cursor = findViewById(R.id.cursor);
int viewMaxX = 0;
int viewMaxY = 0;
for(View view : viewsInDisplay)
{
int[] location = new int[2];
view.getLocationOnScreen(location);
int viewX = location[0] + (view.getWidth() / 2);
int viewY = location[1] / 2;
if(viewX >= viewMaxX)
{
viewMaxX = viewX;
}
if(viewY >= viewMaxY)
{
viewMaxY = viewY;
}
}
if(x > viewMaxX)
{
x = viewMaxX;
}
if(y > viewMaxY)
{
y = viewMaxY;
}
for(View view : viewsInDisplay)
{
int[] location = new int[2];
view.getLocationOnScreen(location);
int viewX = location[0];
int viewY = location[1];
int viewMaxWidth = viewX + view.getWidth();
int viewMinWidth = viewX - view.getWidth();
int viewMaxHeight = viewY + view.getHeight();
int viewMinHeight = viewY - view.getHeight();
if ((x >= viewMinWidth && x <= viewMaxWidth))
{
view.setBackgroundColor(Color.RED);
cursor.animate().x((viewMinWidth + viewMaxWidth) / 2);
cursor.animate().y((viewMinHeight + viewMaxHeight) / 2);
}
else
{
view.setBackgroundColor(Color.BLACK);
}
}
cursor.animate().x(x);
cursor.animate().y(y);
}
} }
\ No newline at end of file
...@@ -134,7 +134,7 @@ public class LowLightEnhanceActivity extends AppCompatActivity ...@@ -134,7 +134,7 @@ public class LowLightEnhanceActivity extends AppCompatActivity
viewsInDisplay.add(findViewById(R.id.back)); viewsInDisplay.add(findViewById(R.id.back));
viewsInDisplay.add(findViewById(R.id.save)); viewsInDisplay.add(findViewById(R.id.select_btn));
computerVision = new ComputerVision(this,this,this); computerVision = new ComputerVision(this,this,this);
...@@ -252,17 +252,10 @@ public class LowLightEnhanceActivity extends AppCompatActivity ...@@ -252,17 +252,10 @@ public class LowLightEnhanceActivity extends AppCompatActivity
} }
void findViewPoint(int x,int y) void findViewPoint(int x,int y)
{ {
ImageView cursor = findViewById(R.id.cursor);
//if(!isPossible) return;
ImageView b = findViewById(R.id.cursor);
int viewMaxX = 0; int viewMaxX = 0;
int viewMinX = 0;
int viewMaxY = 0; int viewMaxY = 0;
int viewMinY = 0;
...@@ -295,23 +288,6 @@ public class LowLightEnhanceActivity extends AppCompatActivity ...@@ -295,23 +288,6 @@ public class LowLightEnhanceActivity extends AppCompatActivity
} }
//
// b.animate().x(x);
// b.animate().y(y);
for(View view : viewsInDisplay) for(View view : viewsInDisplay)
{ {
int[] location = new int[2]; int[] location = new int[2];
...@@ -320,16 +296,6 @@ public class LowLightEnhanceActivity extends AppCompatActivity ...@@ -320,16 +296,6 @@ public class LowLightEnhanceActivity extends AppCompatActivity
int viewX = location[0]; int viewX = location[0];
int viewY = location[1]; int viewY = location[1];
// if(viewX >= viewMaxX)
// {
// viewMaxX = viewX;
// }
// if(viewY >= viewMaxY)
// {
// viewMaxY = viewY;
// }
Log.d("aaaaaaaaaaaa", "View=" + view.getId() + "X=" + viewX + ", Y=" + viewY);
int viewMaxWidth = viewX + view.getWidth(); int viewMaxWidth = viewX + view.getWidth();
int viewMinWidth = viewX - view.getWidth(); int viewMinWidth = viewX - view.getWidth();
...@@ -337,40 +303,14 @@ public class LowLightEnhanceActivity extends AppCompatActivity ...@@ -337,40 +303,14 @@ public class LowLightEnhanceActivity extends AppCompatActivity
int viewMaxHeight = viewY + view.getHeight(); int viewMaxHeight = viewY + view.getHeight();
int viewMinHeight = viewY - view.getHeight(); int viewMinHeight = viewY - view.getHeight();
//b.animate().y((viewMinHeight + viewMaxHeight) / 2);
if ((x >= viewMinWidth && x <= viewMaxWidth)) if ((x >= viewMinWidth && x <= viewMaxWidth))
{ {
if(lastLookedView != null && lastLookedView.getId() == view.getId())
{
count++;
}
else
{
count = 0;
}
if(count >= 3)
{
isPossible = false;
checkCount();
}
view.setBackgroundColor(Color.RED); view.setBackgroundColor(Color.RED);
cursor.animate().x((viewMinWidth + viewMaxWidth) / 2);
cursor.animate().y((viewMinHeight + viewMaxHeight) / 2);
b.animate().x((viewMinWidth + viewMaxWidth) / 2);
b.animate().y((viewMinHeight + viewMaxHeight) / 2);
Log.d("bbbbb", "Came here");
lastLookedView = view;
} }
else else
...@@ -379,8 +319,8 @@ public class LowLightEnhanceActivity extends AppCompatActivity ...@@ -379,8 +319,8 @@ public class LowLightEnhanceActivity extends AppCompatActivity
} }
} }
b.animate().x(x); cursor.animate().x(x);
b.animate().y(y); cursor.animate().y(y);
} }
private void checkCount() private void checkCount()
......
...@@ -103,7 +103,7 @@ public class RestorationActivity extends AppCompatActivity ...@@ -103,7 +103,7 @@ public class RestorationActivity extends AppCompatActivity
viewsInDisplay.add(findViewById(R.id.back)); viewsInDisplay.add(findViewById(R.id.back));
viewsInDisplay.add(findViewById(R.id.save)); viewsInDisplay.add(findViewById(R.id.select_btn));
computerVision = new ComputerVision(this,this,this); computerVision = new ComputerVision(this,this,this);
...@@ -219,17 +219,10 @@ public class RestorationActivity extends AppCompatActivity ...@@ -219,17 +219,10 @@ public class RestorationActivity extends AppCompatActivity
} }
void findViewPoint(int x,int y) void findViewPoint(int x,int y)
{ {
ImageView cursor = findViewById(R.id.cursor);
//if(!isPossible) return;
ImageView b = findViewById(R.id.cursor);
int viewMaxX = 0; int viewMaxX = 0;
int viewMinX = 0;
int viewMaxY = 0; int viewMaxY = 0;
int viewMinY = 0;
...@@ -262,23 +255,6 @@ public class RestorationActivity extends AppCompatActivity ...@@ -262,23 +255,6 @@ public class RestorationActivity extends AppCompatActivity
} }
//
// b.animate().x(x);
// b.animate().y(y);
for(View view : viewsInDisplay) for(View view : viewsInDisplay)
{ {
int[] location = new int[2]; int[] location = new int[2];
...@@ -287,16 +263,6 @@ public class RestorationActivity extends AppCompatActivity ...@@ -287,16 +263,6 @@ public class RestorationActivity extends AppCompatActivity
int viewX = location[0]; int viewX = location[0];
int viewY = location[1]; int viewY = location[1];
// if(viewX >= viewMaxX)
// {
// viewMaxX = viewX;
// }
// if(viewY >= viewMaxY)
// {
// viewMaxY = viewY;
// }
Log.d("aaaaaaaaaaaa", "View=" + view.getId() + "X=" + viewX + ", Y=" + viewY);
int viewMaxWidth = viewX + view.getWidth(); int viewMaxWidth = viewX + view.getWidth();
int viewMinWidth = viewX - view.getWidth(); int viewMinWidth = viewX - view.getWidth();
...@@ -304,40 +270,14 @@ public class RestorationActivity extends AppCompatActivity ...@@ -304,40 +270,14 @@ public class RestorationActivity extends AppCompatActivity
int viewMaxHeight = viewY + view.getHeight(); int viewMaxHeight = viewY + view.getHeight();
int viewMinHeight = viewY - view.getHeight(); int viewMinHeight = viewY - view.getHeight();
//b.animate().y((viewMinHeight + viewMaxHeight) / 2);
if ((x >= viewMinWidth && x <= viewMaxWidth)) if ((x >= viewMinWidth && x <= viewMaxWidth))
{ {
if(lastLookedView != null && lastLookedView.getId() == view.getId())
{
count++;
}
else
{
count = 0;
}
if(count >= 3)
{
isPossible = false;
checkCount();
}
view.setBackgroundColor(Color.RED); view.setBackgroundColor(Color.RED);
cursor.animate().x((viewMinWidth + viewMaxWidth) / 2);
cursor.animate().y((viewMinHeight + viewMaxHeight) / 2);
b.animate().x((viewMinWidth + viewMaxWidth) / 2);
b.animate().y((viewMinHeight + viewMaxHeight) / 2);
Log.d("bbbbb", "Came here");
lastLookedView = view;
} }
else else
...@@ -346,8 +286,8 @@ public class RestorationActivity extends AppCompatActivity ...@@ -346,8 +286,8 @@ public class RestorationActivity extends AppCompatActivity
} }
} }
b.animate().x(x); cursor.animate().x(x);
b.animate().y(y); cursor.animate().y(y);
} }
private void checkCount() private void checkCount()
......
...@@ -24,8 +24,8 @@ public class EyeBlinkDetection ...@@ -24,8 +24,8 @@ public class EyeBlinkDetection
private final int imageSize; private final int imageSize;
private static final int MIN_EYE_CLOSE_COUNT = 0; private static final int MIN_EYE_CLOSE_COUNT = 0;
private static final int LONG_EYE_CLOSE_COUNT = 6; private static final int LONG_EYE_CLOSE_COUNT = 4;
private static final int MAX_EYE_CLOSE_TIME = 10; private static final int MAX_EYE_CLOSE_TIME = 8;
private int eyeCloseCount = MIN_EYE_CLOSE_COUNT; private int eyeCloseCount = MIN_EYE_CLOSE_COUNT;
private final OnEyeStatusChanged listener; private final OnEyeStatusChanged listener;
......
...@@ -109,5 +109,15 @@ ...@@ -109,5 +109,15 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/userSelectedImage" /> app:layout_constraintTop_toTopOf="@+id/userSelectedImage" />
<ImageView
android:id="@+id/cursor"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/cursor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/preview" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -5,21 +5,23 @@ ...@@ -5,21 +5,23 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/white" android:background="@color/white"
android:id="@+id/main_container"
tools:context=".activities.CameraView"> tools:context=".activities.CameraView">
<org.opencv.android.JavaCameraView <ImageView
android:background="@color/colorPrimary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/frame_Surface"/> android:id="@+id/preview"/>
<androidx.constraintlayout.widget.ConstraintLayout <!-- <androidx.constraintlayout.widget.ConstraintLayout-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="match_parent" <!-- android:layout_height="match_parent"-->
android:alpha="0.4" <!-- android:alpha="0.4"-->
android:background="@color/black" <!-- android:background="@color/black"-->
tools:layout_editor_absoluteX="0dp" <!-- tools:layout_editor_absoluteX="0dp"-->
tools:layout_editor_absoluteY="0dp" /> <!-- tools:layout_editor_absoluteY="0dp" />-->
<TextView <TextView
android:id="@+id/textView" android:id="@+id/textView"
...@@ -40,64 +42,52 @@ ...@@ -40,64 +42,52 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageView
<de.hdodenhof.circleimageview.CircleImageView android:id="@+id/left"
android:id="@+id/frame" android:layout_width="100dp"
android:layout_width="130dp" android:layout_height="100dp"
android:layout_height="130dp" android:layout_marginStart="60dp"
android:layout_marginTop="32dp" android:rotation="180"
android:scaleType="centerCrop" android:src="@drawable/arrow"
app:civ_border_color="@color/white" android:visibility="invisible"
app:civ_border_width="2dp" app:layout_constraintBottom_toBottomOf="@+id/preview"
android:src="@drawable/eye"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <ImageView
android:id="@+id/textView1" android:id="@+id/right"
android:layout_width="match_parent" android:layout_width="100dp"
android:layout_height="wrap_content" android:layout_height="100dp"
android:layout_marginStart="32dp" android:layout_marginEnd="60dp"
android:layout_marginTop="12dp" android:src="@drawable/arrow"
android:layout_marginEnd="32dp" android:visibility="invisible"
android:gravity="center" app:layout_constraintBottom_toBottomOf="parent"
android:letterSpacing="0.1"
android:lineSpacingMultiplier="1.2"
android:text="Place your eye"
android:textAllCaps="true"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0" app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/frame" />
<ProgressBar <ImageView
android:id="@+id/progress_bar" android:id="@+id/top"
style="?android:attr/progressBarStyleHorizontal" android:layout_width="100dp"
android:layout_width="match_parent" android:layout_height="100dp"
android:layout_height="wrap_content" android:layout_marginTop="70dp"
android:layout_marginStart="60dp" android:rotation="270"
android:layout_marginTop="50dp" android:src="@drawable/arrow"
android:layout_marginEnd="60dp" android:visibility="invisible"
android:progress="0"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView1" /> app:layout_constraintTop_toBottomOf="@+id/textView" />
<TextView <ImageView
android:id="@+id/view_point" android:id="@+id/bottom"
android:layout_width="match_parent" android:layout_width="100dp"
android:layout_height="wrap_content" android:layout_height="100dp"
android:gravity="center" android:layout_marginBottom="150dp"
android:text="View Point" android:rotation="90"
android:textColor="@android:color/white" android:src="@drawable/arrow"
android:textSize="20sp" android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/frame_Surface" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/frame" /> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -4,17 +4,18 @@ ...@@ -4,17 +4,18 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/white"
tools:context=".activities.SplashScreen"> tools:context=".activities.SplashScreen">
<ImageView <ImageView
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="200dp"
android:scaleType="centerCrop" android:layout_marginStart="50dp"
android:src="@drawable/logo" android:layout_marginEnd="50dp"
android:src="@drawable/icon"
app:layout_constraintBottom_toTopOf="@+id/textView" app:layout_constraintBottom_toTopOf="@+id/textView"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
...@@ -27,7 +28,8 @@ ...@@ -27,7 +28,8 @@
android:text="@string/app_name" android:text="@string/app_name"
android:textAllCaps="true" android:textAllCaps="true"
android:textColor="@color/tools_icon_ash" android:textColor="@color/tools_icon_ash"
android:textSize="21sp" android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline7" /> app:layout_constraintTop_toTopOf="@+id/guideline7" />
...@@ -37,6 +39,6 @@ ...@@ -37,6 +39,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5" /> app:layout_constraintGuide_percent="0.51" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment