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
a3ea3bd0
Commit
a3ea3bd0
authored
Nov 22, 2021
by
dilshan-98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes
parent
5f62c34d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
12 deletions
+65
-12
.idea/compiler.xml
.idea/compiler.xml
+1
-1
Backend/api.py
Backend/api.py
+23
-8
app/build.gradle
app/build.gradle
+1
-1
app/src/main/java/com/app/smartphotoeditor/ImageProcessing/BackgroundCustomization.java
...tphotoeditor/ImageProcessing/BackgroundCustomization.java
+31
-0
app/src/main/java/com/app/smartphotoeditor/activities/EditorActivity.java
...a/com/app/smartphotoeditor/activities/EditorActivity.java
+9
-2
No files found.
.idea/compiler.xml
View file @
a3ea3bd0
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"CompilerConfiguration"
>
<bytecodeTargetLevel
target=
"1
.8
"
/>
<bytecodeTargetLevel
target=
"1
1
"
/>
</component>
</project>
\ No newline at end of file
Backend/api.py
View file @
a3ea3bd0
...
...
@@ -10,6 +10,8 @@ from Vignette import vignette
import
os
import
tensorflow
as
tf
from
flask_ngrok
import
run_with_ngrok
import
base64
app
=
Flask
(
__name__
)
run_with_ngrok
(
app
)
...
...
@@ -21,22 +23,35 @@ app.config["IMAGE_UPLOADS"] = "./"
graph
=
tf
.
get_default_graph
()
def
convert_and_save
(
b64_string
):
with
open
(
"static/theimage.jpg"
,
"wb"
)
as
fh
:
fh
.
write
(
base64
.
decodebytes
(
b64_string
.
encode
()))
@
app
.
route
(
"/"
)
def
hello
():
return
"Checking Connectivity..."
@
app
.
route
(
'/upload'
,
methods
=
[
'POST'
])
@
cross_origin
()
def
upload_file
():
if
request
.
method
==
'POST'
:
if
request
.
files
:
image
=
request
.
files
[
"image"
]
image
.
save
(
os
.
path
.
join
(
app
.
config
[
"IMAGE_UPLOADS"
],
"static/theimage.jpg"
))
global
graph
with
graph
.
as_default
():
mask
()
return
"done"
image
=
request
.
form
.
get
(
'image'
)
convert_and_save
(
image
)
return
"done"
# @app.route('/upload', methods = ['POST'])
# @cross_origin()
# def upload_file():
# if request.method == 'POST':
# if request.files:
# image = request.files["image"]
# image.save(os.path.join(app.config["IMAGE_UPLOADS"], "static/theimage.jpg"))
# global graph
# with graph.as_default():
# mask()
# return "done"
@
app
.
route
(
'/uploadbg'
,
methods
=
[
'POST'
])
...
...
app/build.gradle
View file @
a3ea3bd0
...
...
@@ -21,7 +21,7 @@ android {
}
python
{
buildPython
"C:\\Users\\
user\\AppData\\Local\\Programs\\Python\\Python39
/python.exe"
buildPython
"C:\\Users\\
ACER\\AppData\\Local\\Programs\\Python\\Python36
/python.exe"
pip
{
install
"opencv-contrib-python-headless"
install
"pillow"
...
...
app/src/main/java/com/app/smartphotoeditor/ImageProcessing/BackgroundCustomization.java
View file @
a3ea3bd0
...
...
@@ -9,9 +9,12 @@ import android.app.ProgressDialog;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.provider.MediaStore
;
import
android.util.Base64
;
import
android.util.Log
;
import
android.view.View
;
import
android.webkit.MimeTypeMap
;
...
...
@@ -19,8 +22,12 @@ import android.widget.Button;
import
android.widget.ImageView
;
import
android.widget.Toast
;
import
android.util.Log
;
import
com.app.smartphotoeditor.R
;
import
com.app.smartphotoeditor.config.ImageList
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -40,6 +47,7 @@ public class BackgroundCustomization extends AppCompatActivity
String
f_path
,
filePath
,
fileExtn
;
String
f_extension
;
ProgressDialog
progress
;
Bitmap
inputimage
;
private
static
final
int
REQUEST_EXTERNAL_STORAGE
=
1
;
...
...
@@ -59,6 +67,13 @@ public class BackgroundCustomization extends AppCompatActivity
btnedit
=
(
Button
)
findViewById
(
R
.
id
.
btnedit
);
image
=
findViewById
(
R
.
id
.
img
);
displayFileChoose
();
btnedit
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
...
...
@@ -91,6 +106,8 @@ public class BackgroundCustomization extends AppCompatActivity
public
void
run
()
{
//To upload the image to server
String
input
=
convert
(
ImageList
.
getInstance
().
getCurrentBitmap
());
System
.
out
.
println
(
input
);
File
file
=
new
File
(
f_path
);
String
content_type
=
MimeTypeMap
.
getSingleton
().
getMimeTypeFromExtension
(
f_extension
);
OkHttpClient
okHttpClient
=
new
OkHttpClient
().
newBuilder
()
...
...
@@ -154,6 +171,7 @@ public class BackgroundCustomization extends AppCompatActivity
public
void
displayFileChoose
()
{
Intent
pickPhoto
=
new
Intent
(
Intent
.
ACTION_PICK
,
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
);
pickPhoto
.
setType
(
"image/*"
);
startActivityForResult
(
pickPhoto
,
1
);
...
...
@@ -212,4 +230,17 @@ public class BackgroundCustomization extends AppCompatActivity
Intent
intent
=
new
Intent
(
this
,
Selectedit
.
class
);
startActivity
(
intent
);
}
public
static
Bitmap
convert
(
String
base64Str
)
throws
IllegalArgumentException
{
byte
[]
decodedBytes
=
Base64
.
decode
(
base64Str
.
substring
(
base64Str
.
indexOf
(
","
)
+
1
),
Base64
.
DEFAULT
);
return
BitmapFactory
.
decodeByteArray
(
decodedBytes
,
0
,
decodedBytes
.
length
);
}
public
static
String
convert
(
Bitmap
bitmap
)
{
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
outputStream
);
return
Base64
.
encodeToString
(
outputStream
.
toByteArray
(),
Base64
.
DEFAULT
);
}
}
\ No newline at end of file
app/src/main/java/com/app/smartphotoeditor/activities/EditorActivity.java
View file @
a3ea3bd0
...
...
@@ -2,8 +2,11 @@ package com.app.smartphotoeditor.activities;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Color
;
import
android.os.Bundle
;
import
android.util.Base64
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.Toast
;
...
...
@@ -13,6 +16,7 @@ import androidx.appcompat.app.AppCompatActivity;
import
androidx.constraintlayout.widget.ConstraintLayout
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.app.smartphotoeditor.config.ImageList
;
import
com.app.smartphotoeditor.ImageProcessing.BackgroundCustomization
;
import
com.app.smartphotoeditor.ImageProcessing.Blur
;
...
...
@@ -35,6 +39,7 @@ import com.bumptech.glide.Glide;
import
org.opencv.core.Mat
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.util.ArrayList
;
...
...
@@ -111,10 +116,12 @@ public class EditorActivity extends AppCompatActivity
intent
=
new
Intent
(
getApplicationContext
(),
LowLightEnhanceActivity
.
class
);
else
if
(
clickedPos
==
6
)
intent
=
new
Intent
(
getApplicationContext
(),
MedBlur
.
class
);
else
if
(
clickedPos
==
7
)
else
if
(
clickedPos
==
7
)
{
intent
=
new
Intent
(
getApplicationContext
(),
BackgroundCustomization
.
class
);
else
if
(
clickedPos
==
8
)
}
else
if
(
clickedPos
==
8
){
intent
=
new
Intent
(
getApplicationContext
(),
Blur
.
class
);
}
else
if
(
clickedPos
==
9
)
intent
=
new
Intent
(
getApplicationContext
(),
Bokeh
.
class
);
else
if
(
clickedPos
==
10
)
...
...
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