Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-81
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
2022-81
2022-81
Commits
2242bd73
Commit
2242bd73
authored
Oct 09, 2022
by
ranthilina99
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update growth height and python
parent
15680fad
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
37 deletions
+57
-37
app/.gitignore
app/.gitignore
+1
-1
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+3
-3
app/src/main/assets/dictT.txt
app/src/main/assets/dictT.txt
+2
-0
app/src/main/java/com/example/eketha/GrowthHeight.java
app/src/main/java/com/example/eketha/GrowthHeight.java
+22
-7
app/src/main/python/height.py
app/src/main/python/height.py
+29
-26
No files found.
app/.gitignore
View file @
2242bd73
/build
/src/main/assets
\ No newline at end of file
/src/main/assets/model.tflite
\ No newline at end of file
app/src/main/AndroidManifest.xml
View file @
2242bd73
...
...
@@ -21,7 +21,8 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/Theme.EKetha"
>
<activity
android:name=
".SplashScreen"
<activity
android:name=
".SplashScreen"
android:exported=
"true"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
@@ -33,10 +34,9 @@
<activity
android:name=
".GrowthThreatment"
/>
<activity
android:name=
".GrowthDetect"
/>
<activity
android:name=
".Admin"
/>
<activity
android:name=
".growthHome"
/>
<activity
android:name=
".Growth"
/>
<activity
android:name=
".Register"
/>
<activity
android:name=
".Login"
/>
<activity
android:name=
".Login"
/>
<activity
android:name=
".MainActivity"
/>
<provider
...
...
app/src/main/assets/dictT.txt
0 → 100644
View file @
2242bd73
rice
weed
app/src/main/java/com/example/eketha/GrowthHeight.java
View file @
2242bd73
...
...
@@ -13,6 +13,7 @@ import android.util.Base64;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.Toast
;
import
com.chaquo.python.PyObject
;
import
com.chaquo.python.Python
;
...
...
@@ -21,6 +22,8 @@ import com.chaquo.python.android.AndroidPlatform;
import
java.io.ByteArrayOutputStream
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.lang.reflect.Array
;
import
java.util.ArrayList
;
public
class
GrowthHeight
extends
AppCompatActivity
{
...
...
@@ -127,13 +130,25 @@ public class GrowthHeight extends AppCompatActivity {
PyObject
pyo
=
py
.
getModule
(
"height"
);
PyObject
obj
=
pyo
.
callAttr
(
"main"
,
imageString
);
//System.out.println("-----------------------------------");
System
.
out
.
println
(
obj
);
// ArrayList<PyObject> arrayList = new ArrayList<PyObject>();
// System.out.println("-----------------------------------");
// arrayList.add(obj);
// System.out.println(arrayList);
String
str
=
obj
.
toString
();
byte
data
[]
=
Base64
.
decode
(
str
,
Base64
.
DEFAULT
);
Bitmap
bmp
=
BitmapFactory
.
decodeByteArray
(
data
,
0
,
data
.
length
);
outputImage
=
bmp
;
//System.out.println("-----------------------------------");
//System.out.println(obj);
//System.out.println(str);
//System.out.println("33333333333333333333333333333333333 ");
if
(
str
.
equals
(
"abc"
)){
Toast
.
makeText
(
this
,
"Please upload quality image"
,
Toast
.
LENGTH_SHORT
).
show
();
// Intent intent = new Intent(GrowthHeight.this, growthHome.class);
// startActivity(intent);
}
else
{
byte
data
[]
=
Base64
.
decode
(
str
,
Base64
.
DEFAULT
);
Bitmap
bmp
=
BitmapFactory
.
decodeByteArray
(
data
,
0
,
data
.
length
);
outputImage
=
bmp
;
}
}
}
\ No newline at end of file
app/src/main/python/height.py
View file @
2242bd73
...
...
@@ -36,35 +36,38 @@ def main(data):
cnts
=
imutils
.
grab_contours
(
cnts
)
(
cnts
,
_
)
=
contours
.
sort_contours
(
cnts
)
cnts
=
[
x
for
x
in
cnts
if
cv2
.
contourArea
(
x
)
>
2000
]
ref_object
=
cnts
[
0
]
box
=
cv2
.
minAreaRect
(
ref_object
)
box
=
cv2
.
boxPoints
(
box
)
box
=
np
.
array
(
box
,
dtype
=
"int"
)
box
=
perspective
.
order_points
(
box
)
(
tl
,
tr
,
br
,
bl
)
=
box
dist_in_pixel
=
euclidean
(
tl
,
tr
)
dist_in_cm
=
10
pixel_per_cm
=
dist_in_pixel
/
dist_in_cm
for
cnt
in
cnts
:
box
=
cv2
.
minAreaRect
(
cnt
)
if
len
(
cnts
)
>
0
:
ref_object
=
cnts
[
0
]
box
=
cv2
.
minAreaRect
(
ref_object
)
box
=
cv2
.
boxPoints
(
box
)
box
=
np
.
array
(
box
,
dtype
=
"int"
)
box
=
perspective
.
order_points
(
box
)
(
tl
,
tr
,
br
,
bl
)
=
box
cv2
.
drawContours
(
out_img
,
[
box
.
astype
(
"int"
)],
-
1
,
(
0
,
0
,
255
),
2
)
mid_pt_horizontal
=
(
tl
[
0
]
+
int
(
abs
(
tr
[
0
]
-
tl
[
0
])
/
2
),
tl
[
1
]
+
int
(
abs
(
tr
[
1
]
-
tl
[
1
])
/
2
))
mid_pt_verticle
=
(
tr
[
0
]
+
int
(
abs
(
tr
[
0
]
-
br
[
0
])
/
2
),
tr
[
1
]
+
int
(
abs
(
tr
[
1
]
-
br
[
1
])
/
2
))
wid
=
euclidean
(
tl
,
tr
)
/
pixel_per_cm
ht
=
euclidean
(
tr
,
br
)
/
pixel_per_cm
cv2
.
putText
(
out_img
,
"{:.1f}cm"
.
format
(
ht
),
(
int
(
mid_pt_verticle
[
0
]
+
10
),
int
(
mid_pt_verticle
[
1
])),
cv2
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
(
0
,
0
,
5
),
2
)
dist_in_pixel
=
euclidean
(
tl
,
tr
)
dist_in_cm
=
10
pixel_per_cm
=
dist_in_pixel
/
dist_in_cm
for
cnt
in
cnts
:
box
=
cv2
.
minAreaRect
(
cnt
)
box
=
cv2
.
boxPoints
(
box
)
box
=
np
.
array
(
box
,
dtype
=
"int"
)
box
=
perspective
.
order_points
(
box
)
(
tl
,
tr
,
br
,
bl
)
=
box
cv2
.
drawContours
(
out_img
,
[
box
.
astype
(
"int"
)],
-
1
,
(
0
,
0
,
255
),
2
)
mid_pt_horizontal
=
(
tl
[
0
]
+
int
(
abs
(
tr
[
0
]
-
tl
[
0
])
/
2
),
tl
[
1
]
+
int
(
abs
(
tr
[
1
]
-
tl
[
1
])
/
2
))
mid_pt_verticle
=
(
tr
[
0
]
+
int
(
abs
(
tr
[
0
]
-
br
[
0
])
/
2
),
tr
[
1
]
+
int
(
abs
(
tr
[
1
]
-
br
[
1
])
/
2
))
wid
=
euclidean
(
tl
,
tr
)
/
pixel_per_cm
ht
=
euclidean
(
tr
,
br
)
/
pixel_per_cm
cv2
.
putText
(
out_img
,
"{:.1f}cm"
.
format
(
ht
),
(
int
(
mid_pt_verticle
[
0
]
+
10
),
int
(
mid_pt_verticle
[
1
])),
cv2
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
(
0
,
0
,
5
),
2
)
pil_img
=
Image
.
fromarray
(
out_img
)
buff
=
io
.
BytesIO
()
pil_img
.
save
(
buff
,
format
=
"JPEG"
)
pil_img
=
Image
.
fromarray
(
out_img
)
buff
=
io
.
BytesIO
()
pil_img
.
save
(
buff
,
format
=
"JPEG"
)
#encode the image
img_str
=
base64
.
b64encode
(
buff
.
getvalue
())
return
""
+
str
(
img_str
,
'utf-8'
)
\ No newline at end of file
#encode the image
img_str
=
base64
.
b64encode
(
buff
.
getvalue
())
return
""
+
str
(
img_str
,
'utf-8'
)
else
:
return
"abc"
\ 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