Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-129
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-129
2021-129
Commits
9a53cc6f
Commit
9a53cc6f
authored
Oct 17, 2021
by
samesh97
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes
parent
b28d0611
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
795 additions
and
280 deletions
+795
-280
app/build.gradle
app/build.gradle
+1
-1
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+0
-1
app/src/main/java/com/app/smartphotoeditor/activities/AdjustBrightness.java
...com/app/smartphotoeditor/activities/AdjustBrightness.java
+19
-0
app/src/main/java/com/app/smartphotoeditor/activities/AdjustSaturation.java
...com/app/smartphotoeditor/activities/AdjustSaturation.java
+19
-0
app/src/main/java/com/app/smartphotoeditor/activities/EditorActivity.java
...a/com/app/smartphotoeditor/activities/EditorActivity.java
+0
-1
app/src/main/java/com/app/smartphotoeditor/activities/GalleryPickerActivity.java
...pp/smartphotoeditor/activities/GalleryPickerActivity.java
+0
-229
app/src/main/java/com/app/smartphotoeditor/activities/LowLightEnhanceActivity.java
.../smartphotoeditor/activities/LowLightEnhanceActivity.java
+319
-1
app/src/main/java/com/app/smartphotoeditor/activities/RestorationActivity.java
.../app/smartphotoeditor/activities/RestorationActivity.java
+318
-1
app/src/main/java/com/app/smartphotoeditor/vision/EyeBlinkDetection.java
...va/com/app/smartphotoeditor/vision/EyeBlinkDetection.java
+2
-1
app/src/main/res/layout/activity_low_light_enhance.xml
app/src/main/res/layout/activity_low_light_enhance.xml
+62
-18
app/src/main/res/layout/activity_restoration.xml
app/src/main/res/layout/activity_restoration.xml
+55
-27
No files found.
app/build.gradle
View file @
9a53cc6f
...
...
@@ -21,7 +21,7 @@ android {
}
python
{
buildPython
"C:
/Users/Acer/AppData/Local/Programs/Python/Python38
/python.exe"
buildPython
"C:
\\Users\\user\\AppData\\Local\\Programs\\Python\\Python39
/python.exe"
pip
{
install
"opencv-contrib-python-headless"
install
"pillow"
...
...
app/src/main/AndroidManifest.xml
View file @
9a53cc6f
...
...
@@ -42,7 +42,6 @@
<activity
android:name=
".activities.EditorActivity"
/>
<activity
android:name=
".activities.GalleryPickerActivity"
/>
<activity
android:name=
".activities.RestorationActivity"
/>
<activity
android:name=
".activities.LowLightEnhanceActivity"
/>
<activity
...
...
app/src/main/java/com/app/smartphotoeditor/activities/AdjustBrightness.java
View file @
9a53cc6f
...
...
@@ -49,6 +49,25 @@ public class AdjustBrightness extends AppCompatActivity
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
);
...
...
app/src/main/java/com/app/smartphotoeditor/activities/AdjustSaturation.java
View file @
9a53cc6f
...
...
@@ -49,6 +49,25 @@ public class AdjustSaturation extends AppCompatActivity
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
)
{
...
...
app/src/main/java/com/app/smartphotoeditor/activities/EditorActivity.java
View file @
9a53cc6f
...
...
@@ -37,7 +37,6 @@ public class EditorActivity extends AppCompatActivity
private
ImageView
userSelectedImage
;
private
static
final
int
PICK_IMAGE_REQUEST
=
234
;
private
Methods
methods
;
private
ComputerVision
computerVision
;
...
...
app/src/main/java/com/app/smartphotoeditor/activities/GalleryPickerActivity.java
deleted
100644 → 0
View file @
b28d0611
package
com.app.smartphotoeditor.activities
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.provider.MediaStore
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.AppCompatActivity
;
import
com.app.smartphotoeditor.R
;
import
com.app.smartphotoeditor.adapters.LoadingDialogAdapter
;
import
org.opencv.android.OpenCVLoader
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
public
class
GalleryPickerActivity
extends
AppCompatActivity
{
Button
pickBtn
,
btnForEnhance
,
btnForDenoise
,
btnForRestoration
;
private
Bitmap
image
,
pickedImage
,
outputImage
,
editedImage
=
null
;
private
ImageView
mainImage
;
private
TextView
titleEnhancementMethod
;
private
Handler
handler
=
null
;
private
LoadingDialogAdapter
loadingDialog
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_gallery_picker_2
);
OpenCVLoader
.
initDebug
();
mainImage
=
(
ImageView
)
findViewById
(
R
.
id
.
mainImage
);
pickBtn
=
(
Button
)
findViewById
(
R
.
id
.
pickBtn
);
btnForEnhance
=
(
Button
)
findViewById
(
R
.
id
.
button_light
);
btnForDenoise
=
(
Button
)
findViewById
(
R
.
id
.
buttonDenoise
);
btnForRestoration
=
(
Button
)
findViewById
(
R
.
id
.
buttonRestoration
);
titleEnhancementMethod
=
(
TextView
)
findViewById
(
R
.
id
.
textView13
);
loadingDialog
=
new
LoadingDialogAdapter
(
GalleryPickerActivity
.
this
);
titleEnhancementMethod
.
setVisibility
(
View
.
GONE
);
pickBtn
.
setText
(
"PICK AN IMAGE"
);
btnForEnhance
.
setVisibility
(
View
.
GONE
);
btnForDenoise
.
setVisibility
(
View
.
GONE
);
btnForRestoration
.
setVisibility
(
View
.
GONE
);
String
filename
=
getIntent
().
getStringExtra
(
"editedimage"
);
try
{
FileInputStream
is
=
this
.
openFileInput
(
filename
);
editedImage
=
BitmapFactory
.
decodeStream
(
is
);
if
(
editedImage
!=
null
)
{
visibleButtons
();
mainImage
.
setImageBitmap
(
editedImage
);
}
is
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
void
openGallery2
(
View
v
)
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_PICK
,
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
);
loadingDialog
.
startLoadingDialog
();
startActivityForResult
(
intent
,
101
);
loadingDialog
.
dismissDialog
();
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
@Nullable
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
requestCode
==
101
&&
resultCode
==
RESULT_OK
&&
data
!=
null
)
{
Uri
imageUri
=
data
.
getData
();
image
=
getBitmap
(
imageUri
);
loadingDialog
.
startLoadingDialog
();
new
Thread
()
{
public
void
run
()
{
loadImage
(
getBitmap
(
imageUri
));
handler
.
sendEmptyMessage
(
0
);
}
}.
start
();
handler
=
new
Handler
()
{
public
void
handleMessage
(
android
.
os
.
Message
msg
)
{
visibleButtons
();
mainImage
.
setImageBitmap
(
pickedImage
);
loadingDialog
.
dismissDialog
();
};
};
}
}
private
void
visibleButtons
()
{
btnForEnhance
.
setVisibility
(
View
.
VISIBLE
);
titleEnhancementMethod
.
setVisibility
(
View
.
VISIBLE
);
pickBtn
.
setText
(
"PICK AN ANOTHER IMAGE"
);
btnForDenoise
.
setVisibility
(
View
.
VISIBLE
);
btnForRestoration
.
setVisibility
(
View
.
VISIBLE
);
}
private
Bitmap
getBitmap
(
Uri
imageUri
)
{
Bitmap
bitmapImg
=
null
;
try
{
InputStream
inputStream
=
getContentResolver
().
openInputStream
(
imageUri
);
bitmapImg
=
BitmapFactory
.
decodeStream
(
inputStream
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
bitmapImg
;
}
private
void
loadImage
(
Bitmap
bit
)
{
pickedImage
=
bit
;
}
public
void
goToRestoration
(
View
v
)
{
loadingDialog
.
startLoadingDialog
();
BitmapDrawable
drawable
=
(
BitmapDrawable
)
mainImage
.
getDrawable
();
outputImage
=
drawable
.
getBitmap
();
try
{
//Write file
String
filename
=
"bitmap.png"
;
FileOutputStream
stream
=
this
.
openFileOutput
(
filename
,
Context
.
MODE_PRIVATE
);
outputImage
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
stream
);
//Cleanup
stream
.
close
();
outputImage
.
recycle
();
//Pop intent
Intent
in1
=
new
Intent
(
this
,
RestorationActivity
.
class
);
//change this
in1
.
putExtra
(
"image"
,
filename
);
startActivity
(
in1
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
void
goToDenosing
(
View
v
)
{
loadingDialog
.
startLoadingDialog
();
BitmapDrawable
drawable
=
(
BitmapDrawable
)
mainImage
.
getDrawable
();
outputImage
=
drawable
.
getBitmap
();
try
{
//Write file
String
filename
=
"bitmap.png"
;
FileOutputStream
stream
=
this
.
openFileOutput
(
filename
,
Context
.
MODE_PRIVATE
);
outputImage
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
stream
);
//Cleanup
stream
.
close
();
outputImage
.
recycle
();
//Pop intent
Intent
in1
=
new
Intent
(
this
,
DenoisingActivity
.
class
);
//change this
in1
.
putExtra
(
"image"
,
filename
);
startActivity
(
in1
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
void
goToLightEnhance
(
View
v
)
{
loadingDialog
.
startLoadingDialog
();
BitmapDrawable
drawable
=
(
BitmapDrawable
)
mainImage
.
getDrawable
();
outputImage
=
drawable
.
getBitmap
();
try
{
//Write file
String
filename
=
"bitmap.png"
;
FileOutputStream
stream
=
this
.
openFileOutput
(
filename
,
Context
.
MODE_PRIVATE
);
outputImage
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
stream
);
//Cleanup
stream
.
close
();
outputImage
.
recycle
();
//Pop intent
Intent
in1
=
new
Intent
(
this
,
LowLightEnhanceActivity
.
class
);
//change this
in1
.
putExtra
(
"image"
,
filename
);
startActivity
(
in1
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
app/src/main/java/com/app/smartphotoeditor/activities/LowLightEnhanceActivity.java
View file @
9a53cc6f
...
...
@@ -5,6 +5,7 @@ import android.content.Intent;
import
android.database.Cursor
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Color
;
import
android.graphics.Point
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.media.ExifInterface
;
...
...
@@ -14,8 +15,16 @@ import android.os.Bundle;
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.EqualizeHistogram
;
import
com.app.smartphotoeditor.services.LightEnhancement
;
import
com.app.smartphotoeditor.services.SpeechService
;
import
com.chaquo.python.Python
;
import
com.chaquo.python.android.AndroidPlatform
;
import
com.google.android.material.floatingactionbutton.FloatingActionButton
;
...
...
@@ -24,9 +33,11 @@ import com.google.android.material.snackbar.Snackbar;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.widget.Toolbar
;
import
androidx.constraintlayout.widget.ConstraintLayout
;
import
android.os.Handler
;
import
android.provider.MediaStore
;
import
android.util.Log
;
import
android.view.Display
;
import
android.view.View
;
import
android.view.WindowManager
;
...
...
@@ -38,6 +49,7 @@ import android.widget.TextView;
import
android.widget.ToggleButton
;
import
com.app.smartphotoeditor.R
;
import
com.warkiz.tickseekbar.TickSeekBar
;
import
org.opencv.android.OpenCVLoader
;
import
org.opencv.android.Utils
;
...
...
@@ -51,8 +63,10 @@ import java.io.FileNotFoundException;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
public
class
LowLightEnhanceActivity
extends
AppCompatActivity
{
public
class
LowLightEnhanceActivity
extends
AppCompatActivity
implements
OnGestureDetected
,
OnEyeStatusChanged
,
OnVoiceCommandResultChanged
{
//Variables
private
ImageView
imageDisplay
;
...
...
@@ -64,6 +78,34 @@ public class LowLightEnhanceActivity extends AppCompatActivity {
Thread
lowlightThread
;
private
EqualizeHistogram
equalizeHistogram
;
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
);
...
...
@@ -88,6 +130,56 @@ public class LowLightEnhanceActivity extends AppCompatActivity {
loadingDialog
.
dismissDialog
();
autoEnhanceImage
();
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
(
LowLightEnhanceActivity
.
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
setPreviewFrame
(
Mat
previewMat
)
{
ImageView
preview
=
findViewById
(
R
.
id
.
preview
);
Bitmap
previewBitmap
=
Methods
.
matToBit
(
previewMat
);
previewBitmap
=
Methods
.
rotateBitmap
(
previewBitmap
,-
90
f
);
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
(
inputImage
!=
null
)
{
ImageList
.
getInstance
().
addBitmap
(
inputImage
,
true
);
}
Back
(
null
);
}
...
...
@@ -155,6 +247,232 @@ public class LowLightEnhanceActivity extends AppCompatActivity {
revertButton
.
setText
(
"TURN OFF"
);
}
}
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
()
{
}
}
app/src/main/java/com/app/smartphotoeditor/activities/RestorationActivity.java
View file @
9a53cc6f
...
...
@@ -4,27 +4,42 @@ 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.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.Toast
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.constraintlayout.widget.ConstraintLayout
;
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.ImageRestoration
;
import
com.app.smartphotoeditor.services.SpeechService
;
import
com.chaquo.python.Python
;
import
com.chaquo.python.android.AndroidPlatform
;
import
org.opencv.core.Mat
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.util.ArrayList
;
public
class
RestorationActivity
extends
AppCompatActivity
{
public
class
RestorationActivity
extends
AppCompatActivity
implements
OnGestureDetected
,
OnEyeStatusChanged
,
OnVoiceCommandResultChanged
{
private
Bitmap
inputImage
,
outputImage
,
editedImage
;
private
ImageView
imageDisplay
;
...
...
@@ -34,6 +49,33 @@ public class RestorationActivity extends AppCompatActivity {
private
LoadingDialogAdapter
loadingDialog
;
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
);
...
...
@@ -59,6 +101,25 @@ public class RestorationActivity extends AppCompatActivity {
autoRestoredImage
();
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
(
RestorationActivity
.
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
);
}
public
void
switchImages
(
View
v
)
{
...
...
@@ -122,5 +183,261 @@ public class RestorationActivity extends AppCompatActivity {
e
.
printStackTrace
();
}
}
private
void
setPreviewFrame
(
Mat
previewMat
)
{
ImageView
preview
=
findViewById
(
R
.
id
.
preview
);
Bitmap
previewBitmap
=
Methods
.
matToBit
(
previewMat
);
previewBitmap
=
Methods
.
rotateBitmap
(
previewBitmap
,-
90
f
);
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
(
editedImage
!=
null
)
{
ImageList
.
getInstance
().
addBitmap
(
editedImage
,
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
()
{
}
}
\ No newline at end of file
app/src/main/java/com/app/smartphotoeditor/vision/EyeBlinkDetection.java
View file @
9a53cc6f
...
...
@@ -85,10 +85,11 @@ public class EyeBlinkDetection
eyeCloseCount
+=
1
;
if
(
eyeCloseCount
>=
LONG_EYE_CLOSE_COUNT
&&
eyeCloseCount
<=
MAX_EYE_CLOSE_TIME
)
{
eyeCloseCount
=
MIN_EYE_CLOSE_COUNT
;
//long
listener
.
longClosed
();
speak
(
"Button Clicked"
);
eyeCloseCount
=
MIN_EYE_CLOSE_COUNT
;
}
else
if
(
eyeCloseCount
>
MAX_EYE_CLOSE_TIME
)
{
...
...
app/src/main/res/layout/activity_low_light_enhance.xml
View file @
9a53cc6f
...
...
@@ -4,15 +4,24 @@
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:id=
"@+id/constraint_main"
android:background=
"@android:color/white"
tools:context=
".activities.LowLightEnhanceActivity"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/constraintLayout4"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
/>
<ImageView
android:id=
"@+id/curvebackground"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:adjustViewBounds=
"true"
android:background=
"@
drawable/bottom_curve_background
"
android:background=
"@
color/white
"
app:layout_constraintBottom_toTopOf=
"@+id/guideline6"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.0"
...
...
@@ -23,9 +32,8 @@
<ImageView
android:id=
"@+id/imageView2"
android:layout_width=
"328dp"
android:layout_height=
"
61
0dp"
android:layout_height=
"0dp"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginBottom=
"8dp"
android:adjustViewBounds=
"true"
...
...
@@ -34,19 +42,9 @@
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.51"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_to
TopOf=
"parent
"
app:layout_constraintTop_to
BottomOf=
"@+id/progress
"
app:layout_constraintVertical_bias=
"0.576"
/>
<ImageView
android:id=
"@+id/doneBtn"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_marginTop=
"8dp"
android:layout_marginEnd=
"8dp"
android:onClick=
"goToNext"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/saveimage"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/constraintLayout7"
...
...
@@ -58,8 +56,7 @@
android:layout_marginBottom=
"16dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/displayImageDenoise"
>
app:layout_constraintStart_toStartOf=
"parent"
>
<TextView
android:id=
"@+id/textView2"
...
...
@@ -76,7 +73,7 @@
<Button
android:id=
"@+id/revertBtn"
android:layout_width=
"
85dp
"
android:layout_width=
"
wrap_content
"
android:layout_height=
"58dp"
android:layout_alignParentEnd=
"true"
android:layout_alignParentBottom=
"true"
...
...
@@ -99,6 +96,53 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
app:layout_constraintGuide_percent=
"0.83"
/>
app:layout_constraintGuide_percent=
"0.86"
/>
<ImageView
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/imageView2"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"@+id/constraintLayout4"
/>
<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_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
app/src/main/res/layout/activity_restoration.xml
View file @
9a53cc6f
...
...
@@ -5,48 +5,29 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@android:color/white"
android:id=
"@+id/constraint_main"
android:onClick=
"goToNext"
tools:context=
".activities.RestorationActivity"
>
<
ImageView
android:id=
"@+id/c
urvebackground
"
<
androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/c
onstraintLayout4
"
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/displayImageRestore"
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_to
TopOf=
"parent
"
app:layout_constraintTop_to
BottomOf=
"@+id/progress
"
app:layout_constraintVertical_bias=
"0.576"
/>
<ImageView
android:id=
"@+id/imageView3"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_marginTop=
"8dp"
android:layout_marginEnd=
"8dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/saveimage"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/constraintLayout7"
...
...
@@ -63,7 +44,7 @@
<Button
android:id=
"@+id/restoreBtn"
android:layout_width=
"
85dp
"
android:layout_width=
"
wrap_content
"
android:layout_height=
"58dp"
android:layout_alignParentEnd=
"true"
android:layout_alignParentBottom=
"true"
...
...
@@ -101,4 +82,51 @@
android:orientation=
"horizontal"
app:layout_constraintGuide_percent=
"0.83"
/>
<ImageView
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_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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment