Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
LSR_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
awebow
2020-06-16 20:50:54 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5dd1c8657b43c9f9472a3d51ab66802afc4f9db7
5dd1c865
1 parent
74050af6
운동 UI 수정
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
25 deletions
source/android/app/src/main/AndroidManifest.xml
source/android/app/src/main/java/com/khuhacker/pocketgym/ExerciseActivity.java
source/android/app/src/main/res/layout/activity_exercise.xml
source/android/app/src/main/AndroidManifest.xml
View file @
5dd1c86
...
...
@@ -12,15 +12,19 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".FirstActivity"
>
<activity
android:name=
".FirstActivity"
android:screenOrientation=
"portrait"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name =
".ChoiceActivity"
/>
<activity
android:name =
".ExerciseActivity"
/>
<activity
android:name =
".ChoiceActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name =
".ExerciseActivity"
android:screenOrientation=
"landscape"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
/>
<activity
android:name =
".ReportActivity"
/>
</application>
...
...
source/android/app/src/main/java/com/khuhacker/pocketgym/ExerciseActivity.java
View file @
5dd1c86
...
...
@@ -26,6 +26,7 @@ import android.media.Image;
import
android.media.ImageReader
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.util.TypedValue
;
import
android.view.SurfaceHolder
;
import
android.view.SurfaceView
;
import
android.widget.TextView
;
...
...
@@ -54,7 +55,6 @@ public class ExerciseActivity extends AppCompatActivity implements SurfaceHolder
private
Interpreter
interpreter
;
private
int
count
=
0
;
private
boolean
up
=
true
;
private
TextView
countView
;
DBHelper
dbHelper
;
String
getTime
;
...
...
@@ -72,8 +72,6 @@ public class ExerciseActivity extends AppCompatActivity implements SurfaceHolder
surfaceView
=
findViewById
(
R
.
id
.
surfaceView
);
surfaceView
.
getHolder
().
addCallback
(
this
);
countView
=
findViewById
(
R
.
id
.
count
);
try
{
AssetFileDescriptor
fileDescriptor
=
getAssets
().
openFd
(
"pushup.tflite"
);
FileInputStream
is
=
new
FileInputStream
(
fileDescriptor
.
getFileDescriptor
());
...
...
@@ -242,6 +240,8 @@ public class ExerciseActivity extends AppCompatActivity implements SurfaceHolder
if
(
Math
.
abs
(
modelInputRatio
-
bitmapRatio
)
<
maxDifference
)
return
croppedBitmap
;
Matrix
rotate
=
new
Matrix
();
rotate
.
postRotate
(
270
);
if
(
modelInputRatio
<
bitmapRatio
)
{
// New image is taller so we are height constrained.
float
cropHeight
=
bitmap
.
getHeight
()
-
bitmap
.
getWidth
()
/
modelInputRatio
;
...
...
@@ -250,7 +250,8 @@ public class ExerciseActivity extends AppCompatActivity implements SurfaceHolder
0
,
(
int
)
cropHeight
/
2
,
bitmap
.
getWidth
(),
(
int
)
(
bitmap
.
getHeight
()
-
cropHeight
)
(
int
)
(
bitmap
.
getHeight
()
-
cropHeight
),
rotate
,
false
);
}
else
{
...
...
@@ -260,7 +261,8 @@ public class ExerciseActivity extends AppCompatActivity implements SurfaceHolder
(
int
)
(
cropWidth
/
2
),
0
,
(
int
)
(
bitmap
.
getWidth
()
-
cropWidth
),
bitmap
.
getHeight
()
bitmap
.
getHeight
(),
rotate
,
false
);
}
return
croppedBitmap
;
...
...
@@ -280,9 +282,14 @@ public class ExerciseActivity extends AppCompatActivity implements SurfaceHolder
Paint
paint
=
new
Paint
();
Canvas
canvas
=
surfaceView
.
getHolder
().
lockCanvas
();
canvas
.
drawRGB
(
0
,
0
,
0
);
// 이미지 그리기
canvas
.
drawBitmap
(
croppedBitmap
,
new
Rect
(
0
,
0
,
croppedBitmap
.
getWidth
(),
croppedBitmap
.
getHeight
()),
new
Rect
(
0
,
0
,
canvas
.
getWidth
(),
canvas
.
getWidth
()),
paint
);
//float scale = (float) canvas.getWidth() / bitmap.getWidth();
//if(bitmap.getHeight() * scale > canvas.getHeight())
// scale = (float) canvas.getHeight() / bitmap.getHeight();
//canvas.drawBitmap(bitmap, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), new Rect(0, 0, (int) (bitmap.getWidth() * scale), (int) (bitmap.getHeight() * scale)), paint);
canvas
.
drawBitmap
(
croppedBitmap
,
new
Rect
(
0
,
0
,
croppedBitmap
.
getWidth
(),
croppedBitmap
.
getHeight
()),
new
Rect
(
0
,
0
,
canvas
.
getHeight
(),
canvas
.
getHeight
()),
paint
);
float
[][][]
keyMap
=
new
float
[
1
][
257
][
257
];
float
[][]
result
=
new
float
[
1
][
2
];
...
...
@@ -293,7 +300,7 @@ public class ExerciseActivity extends AppCompatActivity implements SurfaceHolder
if
(
keyPoint
.
getScore
()
<
0.7
)
continue
;
canvas
.
drawCircle
((
float
)
keyPoint
.
getPosition
().
getX
()
/
scaledBitmap
.
getWidth
()
*
canvas
.
get
Width
(),
(
float
)
keyPoint
.
getPosition
().
getY
()
/
scaledBitmap
.
getWidth
()
*
canvas
.
getWidth
(),
5
,
paint
);
canvas
.
drawCircle
((
float
)
keyPoint
.
getPosition
().
getX
()
/
scaledBitmap
.
getWidth
()
*
canvas
.
get
Height
(),
(
float
)
keyPoint
.
getPosition
().
getY
()
/
scaledBitmap
.
getWidth
()
*
canvas
.
getHeight
(),
5
,
paint
);
if
(
keyPoint
.
getPosition
().
getX
()
>=
0
&&
keyPoint
.
getPosition
().
getX
()
<
257
&&
keyPoint
.
getPosition
().
getY
()
>=
0
&&
keyPoint
.
getPosition
().
getY
()
<
257
)
keyMap
[
0
][
keyPoint
.
getPosition
().
getY
()][
keyPoint
.
getPosition
().
getX
()]
=
i
+
1
;
}
...
...
@@ -305,25 +312,26 @@ public class ExerciseActivity extends AppCompatActivity implements SurfaceHolder
if
(
result
[
0
][
0
]
>=
0.7
)
{
if
(!
up
)
{
count
++;
countView
.
setText
(
"Count: "
+
count
);
//db에 값 증가
SQLiteDatabase
db
=
dbHelper
.
getReadableDatabase
();
String
sql
=
"SELECT pushup FROM reports WHERE date="
+
getTime
+
";"
;
Cursor
cs
=
db
.
rawQuery
(
sql
,
null
);
cs
.
moveToNext
();
int
before
=
cs
.
getInt
(
0
);
db
=
dbHelper
.
getWritableDatabase
();
sql
=
"UPDATE reports SET pushup='"
+
before
+
1
+
"'
WHERE date="
+
getTime
+
";"
;
String
sql
=
"UPDATE reports SET pushup=pushup+1
WHERE date="
+
getTime
+
";"
;
db
.
execSQL
(
sql
);
}
up
=
true
;
}
else
if
(
result
[
0
][
1
]
>=
0.
7
)
else
if
(
result
[
0
][
1
]
>=
0.
6
)
up
=
false
;
paint
.
setTextAlign
(
Paint
.
Align
.
LEFT
);
int
fontSize
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_SP
,
24
,
getResources
().
getDisplayMetrics
());
paint
.
setTextSize
(
fontSize
);
int
pad
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
16
,
getResources
().
getDisplayMetrics
());
canvas
.
drawText
(
String
.
format
(
"Count: %d"
,
count
),
canvas
.
getHeight
()
+
pad
,
pad
+
fontSize
,
paint
);
surfaceView
.
getHolder
().
unlockCanvasAndPost
(
canvas
);
}
}
...
...
source/android/app/src/main/res/layout/activity_exercise.xml
View file @
5dd1c86
...
...
@@ -12,12 +12,4 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<TextView
android:id=
"@+id/count"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Count: 0"
android:textColor=
"#FF0000"
android:textSize=
"18sp"
/>
</FrameLayout>
\ No newline at end of file
...
...
Please
register
or
login
to post a comment