Commit 674c4033 authored by samesh97's avatar samesh97

minor changes.

parent ecc26d86
......@@ -73,12 +73,14 @@ public class AddEffects extends AppCompatActivity
private ArrayList<View> viewsInDisplay = new ArrayList<>();
private boolean isPossible = true;
private int count = 0;
private View lastLookedView = null;
private ComputerVision computerVision;
int count = 0;
int count2 = 0;
boolean isPossible = true;
......@@ -320,15 +322,7 @@ public class AddEffects extends AppCompatActivity
void findViewPoint(int x,int y)
{
ImageView b = findViewById(R.id.cursor);
int viewMaxX = 0;
int viewMaxY = 0;
for(View view : viewsInDisplay)
{
int[] location = new int[2];
......@@ -337,10 +331,6 @@ public class AddEffects extends AppCompatActivity
int viewX = location[0] + (view.getWidth() / 2);
int viewY = location[1] / 2;
if(viewX >= viewMaxX)
{
viewMaxX = viewX;
}
if(viewY >= viewMaxY)
{
viewMaxY = viewY;
......@@ -348,71 +338,130 @@ public class AddEffects extends AppCompatActivity
}
if(x > viewMaxX)
{
x = viewMaxX;
}
if(y > viewMaxY)
{
y = viewMaxY;
}
ImageView b = findViewById(R.id.cursor);
for(View view : viewsInDisplay)
if(x == 620 || x == 720 || x == 360)
{
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())
{
}
view.setBackgroundColor(Color.RED);
b.animate().x((viewMinWidth + viewMaxWidth) / 2);
b.animate().y((viewMinHeight + viewMaxHeight) / 2);
Log.d("bbbbb", "Came here");
lastLookedView = view;
}
else
{
view.setBackgroundColor(Color.BLACK);
}
viewsInDisplay.get(1).setBackgroundColor(Color.RED);
viewsInDisplay.get(0).setBackgroundColor(Color.BLACK);
}
else
{
viewsInDisplay.get(0).setBackgroundColor(Color.RED);
viewsInDisplay.get(1).setBackgroundColor(Color.BLACK);
}
b.animate().x(x);
b.animate().y(y);
b.animate().y(viewMaxY);
Log.d("XXXXXX","x-" + x);
// ImageView b = 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))
// {
//
// 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
......
package com.app.smartphotoeditor.activities;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
......@@ -19,7 +22,15 @@ import android.widget.TextView;
import com.app.smartphotoeditor.R;
import com.app.smartphotoeditor.adapters.LoadingDialogAdapter;
import com.app.smartphotoeditor.config.ImageList;
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.OnGestureDetected;
import com.app.smartphotoeditor.sdk.Methods;
import com.app.smartphotoeditor.sdk.RealTimeCamera;
import com.app.smartphotoeditor.services.ComputerVision;
import com.app.smartphotoeditor.services.ImageDenoising;
import com.app.smartphotoeditor.services.SpeechService;
import com.chaquo.python.Python;
import com.chaquo.python.android.AndroidPlatform;
......@@ -28,8 +39,10 @@ import org.opencv.core.Mat;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;
public class DenoisingActivity extends AppCompatActivity {
public class DenoisingActivity extends AppCompatActivity
implements OnGestureDetected, OnEyeStatusChanged, OnVoiceCommandResultChanged {
//Variables
private Bitmap inputImage = null, denoisedImage, outputImage;
......@@ -41,6 +54,32 @@ public class DenoisingActivity extends AppCompatActivity {
private boolean switchImage = true, alreadyDenoised = true;
private Handler handler = null;
private ComputerVision computerVision;
private int count = 0;
private View lastLookedView = null;
private ArrayList<View> viewsInDisplay = new ArrayList<>();
private boolean isPossible = true;
private SpeechService speechService;
@Override
protected void onResume() {
super.onResume();
speechService.onResume();
}
@Override
protected void onPause() {
super.onPause();
speechService.onPause();
}
@Override
protected void onStop() {
super.onStop();
speechService.onStop();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -62,6 +101,24 @@ public class DenoisingActivity extends AppCompatActivity {
autoDenoiseImage();
viewsInDisplay.add(findViewById(R.id.back));
viewsInDisplay.add(findViewById(R.id.save));
computerVision = new ComputerVision(this,this,this);
ConstraintLayout constraintLayout = findViewById(R.id.constraint_main);
new RealTimeCamera(DenoisingActivity.this, constraintLayout, new OnCameraPreviewChanged() {
@Override
public void updated(Mat rgba, Mat previewMat)
{
computerVision.setMat(rgba);
setPreviewFrame(previewMat);
}
}).initialize();
speechService = new SpeechService(getApplicationContext(),findViewById(R.id.progress),this);
}
private void autoDenoiseImage() {
......@@ -131,6 +188,262 @@ public class DenoisingActivity extends AppCompatActivity {
}
}
private void setPreviewFrame(Mat previewMat)
{
ImageView preview = findViewById(R.id.preview);
Bitmap previewBitmap = Methods.matToBit(previewMat);
previewBitmap = Methods.rotateBitmap(previewBitmap,-90f);
Bitmap finalPreviewBitmap = previewBitmap;
runOnUiThread(new Runnable() {
@Override
public void run() {
if(preview != null)
preview.setImageBitmap(finalPreviewBitmap);
}
});
}
public void Back(View view)
{
setResult(100);
finish();
}
public void Save(View view)
{
if(outputImage != null)
{
ImageList.getInstance().addBitmap(outputImage,true);
}
Back(null);
}
void findViewPoint(int x,int y)
{
//if(!isPossible) return;
ImageView b = findViewById(R.id.cursor);
int viewMaxX = 0;
int viewMinX = 0;
int viewMaxY = 0;
int viewMinY = 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;
}
//
// b.animate().x(x);
// b.animate().y(y);
for(View view : viewsInDisplay)
{
int[] location = new int[2];
view.getLocationOnScreen(location);
int viewX = location[0];
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 viewMinWidth = viewX - view.getWidth();
int viewMaxHeight = viewY + view.getHeight();
int viewMinHeight = viewY - view.getHeight();
//b.animate().y((viewMinHeight + viewMaxHeight) / 2);
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);
b.animate().x((viewMinWidth + viewMaxWidth) / 2);
b.animate().y((viewMinHeight + viewMaxHeight) / 2);
Log.d("bbbbb", "Came here");
lastLookedView = view;
}
else
{
view.setBackgroundColor(Color.BLACK);
}
}
b.animate().x(x);
b.animate().y(y);
}
private void checkCount()
{
count++;
if(count >= 5)
{
isPossible = true;
count = 0;
}
else
{
isPossible = false;
}
}
@Override
public void opened() {
}
@Override
public void closed() {
}
@Override
public void longClosed() {
}
@Override
public void onPupilChanged(Mat binary, int x, int y, int range, int pupilX) {
findViewPoint(x,y);
}
@Override
public void onIdle() {
}
@Override
public void onLeft() {
}
@Override
public void onRight() {
}
@Override
public void onTop() {
}
@Override
public void onBottom() {
}
@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() {
}
}
......
......@@ -268,6 +268,13 @@ public class EditorActivity extends AppCompatActivity
@Override
public void select() {
runOnUiThread(new Runnable() {
@Override
public void run()
{
toolsAdapter.openTool();
}
});
}
......
......@@ -175,9 +175,9 @@ public class LowLightEnhanceActivity extends AppCompatActivity
public void Save(View view)
{
if(inputImage != null)
if(outputImage != null)
{
ImageList.getInstance().addBitmap(inputImage,true);
ImageList.getInstance().addBitmap(outputImage,true);
}
Back(null);
}
......
......@@ -196,32 +196,32 @@ public class SpeechService implements RecognitionListener
listener.back();
return true;
}
if(audio.equals("exit"))
if(audio.contains("exit"))
{
listener.exit();
return true;
}
if(audio.equals("undo"))
if(audio.contains("undo"))
{
listener.undo();
return true;
}
if(audio.equals("redo")
|| audio.equals("creed 2")
|| audio.equals("read")
|| audio.equals("cree do")
|| audio.equals("free do")
|| audio.equals("video"))
if(audio.contains("redo")
|| audio.contains("creed 2")
|| audio.contains("read")
|| audio.contains("cree do")
|| audio.contains("free do")
|| audio.contains("video"))
{
listener.redo();
return true;
}
if(audio.equals("select"))
if(audio.contains("select"))
{
listener.select();
return true;
}
if(audio.equals("save") || audio.equals("shave"))
if(audio.contains("save") || audio.contains("shave"))
{
listener.save();
return true;
......
......@@ -24,8 +24,8 @@ public class EyeBlinkDetection
private final int imageSize;
private static final int MIN_EYE_CLOSE_COUNT = 0;
private static final int LONG_EYE_CLOSE_COUNT = 4;
private static final int MAX_EYE_CLOSE_TIME = 8;
private static final int LONG_EYE_CLOSE_COUNT = 6;
private static final int MAX_EYE_CLOSE_TIME = 10;
private int eyeCloseCount = MIN_EYE_CLOSE_COUNT;
private final OnEyeStatusChanged listener;
......
......@@ -5,38 +5,29 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:id="@+id/constraint_main"
tools:context=".activities.DenoisingActivity">
<ImageView
android:id="@+id/curvebackground"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:background="@drawable/bottom_curve_background"
app:layout_constraintBottom_toTopOf="@+id/guideline6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_height="match_parent"
android:background="@color/white" />
<ImageView
android:id="@+id/displayImageDenoise"
android:layout_width="328dp"
android:layout_height="610dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
app:layout_constraintBottom_toTopOf="@+id/guideline6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.51"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progress"
app:layout_constraintVertical_bias="0.576" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout7"
android:layout_width="match_parent"
......@@ -50,22 +41,9 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/displayImageDenoise">
<TextView
android:id="@+id/textView3"
android:layout_width="101dp"
android:layout_height="25dp"
android:layout_marginStart="64dp"
android:text="Denoising :"
android:textColor="@color/colorPrimary"
android:textSize="17sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/denoiseBtn"
android:layout_width="85dp"
android:layout_width="wrap_content"
android:layout_height="58dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
......@@ -77,7 +55,20 @@
android:textSize="17sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView3"
app:layout_constraintStart_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="101dp"
android:layout_height="25dp"
android:layout_marginStart="64dp"
android:text="De-noising :"
android:textColor="@color/colorPrimary"
android:textSize="17sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -91,14 +82,50 @@
app:layout_constraintGuide_percent="0.83" />
<ImageView
android:id="@+id/imageView"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:onClick="goToNext"
android:id="@+id/preview"
android:layout_width="120dp"
android:layout_height="120dp"
android:scaleType="centerCrop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:onClick="Back"
android:text="Back"
app:layout_constraintBottom_toTopOf="@+id/progress"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/preview" />
<Button
android:id="@+id/select_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="32dp"
android:onClick="Save"
android:text="Save"
app:layout_constraintBottom_toBottomOf="@+id/back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/back" />
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:max="100"
android:progress="50"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/saveimage" />
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/preview" />
</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