Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
A
ActionCount
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangyanan
ActionCount
Commits
13d1c0c1
Commit
13d1c0c1
authored
Nov 29, 2021
by
zhangyanan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:完善跳跃计数。
parent
51faae0d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
176 additions
and
157 deletions
+176
-157
ActionCountActivity.kt
...rc/main/java/com/health/actiondemo/ActionCountActivity.kt
+176
-121
action_kaihetiao.json
app/src/main/res/raw/action_kaihetiao.json
+0
-18
gameinfo.json
app/src/main/res/raw/gameinfo.json
+0
-18
No files found.
app/src/main/java/com/health/actiondemo/ActionCountActivity.kt
View file @
13d1c0c1
package
com.health.actiondemo
import
android.app.Activity
import
android.graphics.PointF
import
android.os.Bundle
import
android.os.Handler
import
android.os.Looper
...
...
@@ -10,12 +11,15 @@ import android.widget.TextView
import
com.alibaba.fastjson.JSON
import
com.health.baselibrary.utils.StringUtils
import
com.health.videoplay.bean.StandardConditonsModel
import
com.health.videoplay.util.AngleCalculateHelper
import
com.health.videoplay.util.CalFrameDelegate
import
com.healthhope.opengl.PoseCameraView
import
com.healthhope.opengl.utils.LimitQueue
import
java.io.BufferedReader
import
java.io.InputStreamReader
import
java.lang.StringBuilder
import
java.util.HashMap
import
java.util.*
import
kotlin.math.abs
class
ActionCountActivity
:
Activity
()
{
...
...
@@ -32,11 +36,14 @@ class ActionCountActivity : Activity() {
private
val
mainHandler
=
Handler
(
Looper
.
getMainLooper
())
private
var
containJump
=
false
private
var
aCount
=
0
private
var
actionType
=
0
var
mLimitQueue
=
LimitQueue
<
Array
<
PointF
?>?>(
5
)
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_action_count
)
initInfo
()
//
initInfo()
textInfo
=
findViewById
(
R
.
id
.
text_info
)
textCount
=
findViewById
(
R
.
id
.
text_count
)
textResult
=
findViewById
(
R
.
id
.
result_info
)
...
...
@@ -45,16 +52,17 @@ class ActionCountActivity : Activity() {
textDebug2
=
findViewById
(
R
.
id
.
text_debug_2
)
textDebug3
=
findViewById
(
R
.
id
.
text_debug_3
)
val
intExtra
=
intent
.
getIntExtra
(
"actionType"
,
0
)
actionType
=
intent
.
getIntExtra
(
"actionType"
,
0
)
//动作检查
calFrameDelegate
.
setCheckType
(
CalFrameDelegate
.
TYPE_ACTION_CHECK
)
when
(
intExtra
)
{
when
(
actionType
)
{
//蹲起
0
->
{
textInfo
?.
text
=
"蹲起:"
val
info
:
List
<
StandardConditonsModel
>
=
JSON
.
parseArray
(
getRawText
(
R
.
raw
.
action_dunqi
),
StandardConditonsModel
::
class
.
java
)
val
info
:
Mutable
List
<
StandardConditonsModel
>
=
JSON
.
parseArray
(
getRawText
(
R
.
raw
.
action_dunqi
),
StandardConditonsModel
::
class
.
java
)
calFrameDelegate
.
setActionCheckConditions
(
info
)
Log
.
i
(
"ademoademo"
,
"info---》"
+
Arrays
.
toString
(
info
.
toTypedArray
()))
}
//开合跳
1
->
{
...
...
@@ -66,19 +74,17 @@ class ActionCountActivity : Activity() {
//跳
2
->
{
textInfo
?.
text
=
"跳跃:"
}
}
calFrameDelegate
.
setGainResultListener
(
object
:
CalFrameDelegate
.
OnGainResultListener
{
override
fun
onResult
(
conditonsModel
:
StandardConditonsModel
?,
result
:
Byte
)
{
Log
.
i
(
"ademo"
,
"result--->"
+
result
)
setResult
(
result
.
toString
())
when
(
result
)
{
CalFrameDelegate
.
ResultCode
.
RESULT_OK
->
{
if
(
containJump
)
{
//
if (poseView?.getRenderHelper()?.isJump == true) {
if
(
poseView
?.
getRenderHelper
()
?.
isJump
==
true
)
{
updateInfo
()
//
}
}
}
else
{
updateInfo
()
}
...
...
@@ -91,73 +97,122 @@ class ActionCountActivity : Activity() {
}
})
calFrameDelegate
.
setInfoListener
(
object
:
CalFrameDelegate
.
OnInfoListener
{
override
fun
onConstantInfo
(
constants
:
MutableMap
<
String
,
Double
>?)
{
val
sb
=
StringBuilder
()
for
((
key
,
value
)
in
constants
!!
)
{
sb
.
append
(
transConstantsNameToCh
(
key
)
+
":"
+
StringUtils
.
formatNum
(
value
,
1
))
.
append
(
"\n"
)
}
mainHandler
.
post
{
textDebug1
?.
text
=
sb
.
toString
()
// calFrameDelegate.setInfoListener(object: CalFrameDelegate.OnInfoListener{
// override fun onConstantInfo(constants: MutableMap<String, Double>?) {
// val sb = StringBuilder()
// for ((key, value) in constants!!) {
// sb.append(transConstantsNameToCh(key) + ":" + StringUtils.formatNum(value, 1))
// .append("\n")
// }
// mainHandler.post{
// textDebug1?.text = sb.toString()
//
// }
// }
//
// override fun onCondition(conditionType: String?, bodyKeys: MutableList<String>?, ax: Double, a: Double, b: Double, by: Double) {
// if (TextUtils.isEmpty(conditionType)) {
// runOnUiThread { textDebug2?.setText("无标注信息") }
// return
// }
// val sb = StringBuilder()
//
// if ("0" == conditionType) {
// sb.append("角度").append("\n")
// } else if ("1" == conditionType) {
// sb.append("高差").append("\n")
// } else if ("2" == conditionType) {
// sb.append("水平差").append("\n")
// } else {
// sb.append("距离").append("\n")
// }
//// sb.append("conditionType:" + conditionType).append("\n");
// // sb.append("conditionType:" + conditionType).append("\n");
// sb.append("calPoints:")
// for (i in bodyKeys!!.indices) {
// if (i < bodyKeys.size - 1) {
// sb.append(pointChNames.get(bodyKeys[i])).append("_")
// } else {
// sb.append(pointChNames.get(bodyKeys[i]))
// }
// }
// sb.append("\n")
// sb.append("ax=").append(StringUtils.formatNum(ax, 1)).append("\n")
// .append("a=").append(StringUtils.formatNum(a, 1)).append("\n")
// .append("b=").append(StringUtils.formatNum(b, 1)).append("\n")
// .append("by=").append(StringUtils.formatNum(by, 1))
// runOnUiThread { textDebug2?.setText(sb.toString()) }
// }
//
// override fun onCalInfo(calResult: Double) {
// var cal = calResult
// if (java.lang.Double.isNaN(cal) || java.lang.Double.isInfinite(cal)) {
// cal = 0.0
// }
// runOnUiThread {
// textDebug3?.setText(
// """
// calResult:
// ${StringUtils.formatNum(cal, 1)}
// """.trimIndent()
// )
// }
// }
//
// })
poseView
=
findViewById
(
R
.
id
.
pose_camera
)
poseView
?.
getRenderHelper
()
?.
setOnFrameListener
{
pointFS
->
if
(
actionType
!=
2
)
{
calFrameDelegate
.
onFrame
(
pointFS
)
}
else
{
if
(
mLimitQueue
.
size
==
0
)
{
mLimitQueue
.
offer
(
pointFS
)
}
else
if
(
mOrderFlag
%
2
==
0
)
{
mLimitQueue
.
offer
(
pointFS
)
mOrderFlag
=
0
}
mOrderFlag
++
checkJump
()
}
}
}
override
fun
onCondition
(
conditionType
:
String
?,
bodyKeys
:
MutableList
<
String
>?,
ax
:
Double
,
a
:
Double
,
b
:
Double
,
by
:
Double
)
{
if
(
TextUtils
.
isEmpty
(
conditionType
))
{
runOnUiThread
{
textDebug2
?.
setText
(
"无标注信息"
)
}
return
}
val
sb
=
StringBuilder
()
if
(
"0"
==
conditionType
)
{
sb
.
append
(
"角度"
).
append
(
"\n"
)
}
else
if
(
"1"
==
conditionType
)
{
sb
.
append
(
"高差"
).
append
(
"\n"
)
}
else
if
(
"2"
==
conditionType
)
{
sb
.
append
(
"水平差"
).
append
(
"\n"
)
}
else
{
sb
.
append
(
"距离"
).
append
(
"\n"
)
}
// sb.append("conditionType:" + conditionType).append("\n");
// sb.append("conditionType:" + conditionType).append("\n");
sb
.
append
(
"calPoints:"
)
for
(
i
in
bodyKeys
!!
.
indices
)
{
if
(
i
<
bodyKeys
.
size
-
1
)
{
sb
.
append
(
pointChNames
.
get
(
bodyKeys
[
i
])).
append
(
"_"
)
}
else
{
sb
.
append
(
pointChNames
.
get
(
bodyKeys
[
i
]))
}
}
sb
.
append
(
"\n"
)
sb
.
append
(
"ax="
).
append
(
StringUtils
.
formatNum
(
ax
,
1
)).
append
(
"\n"
)
.
append
(
"a="
).
append
(
StringUtils
.
formatNum
(
a
,
1
)).
append
(
"\n"
)
.
append
(
"b="
).
append
(
StringUtils
.
formatNum
(
b
,
1
)).
append
(
"\n"
)
.
append
(
"by="
).
append
(
StringUtils
.
formatNum
(
by
,
1
))
runOnUiThread
{
textDebug2
?.
setText
(
sb
.
toString
())
}
//每隔一帧取一次
private
var
mOrderFlag
=
0
private
var
isUp
=
false
private
fun
checkJump
()
{
if
(
mLimitQueue
.
size
>
1
)
{
val
queue
=
Array
(
mLimitQueue
.
size
)
{
arrayOfNulls
<
PointF
>(
14
)
}
mLimitQueue
.
toArray
(
queue
)
//阈值为鼻子到脖子之间的距离
val
thresholdVal
=
abs
(
AngleCalculateHelper
.
yDiff
(
queue
[
0
][
1
],
queue
[
0
][
0
]))
*
0.1f
val
last
=
queue
.
size
-
1
val
movedistance1
=
AngleCalculateHelper
.
yDiff
(
queue
[
last
][
2
],
queue
[
last
-
1
][
2
])
// MLog.d(TAG, "__部位:左肩_____________竖直移动距离:$movedistance1")
val
movedistance2
=
AngleCalculateHelper
.
yDiff
(
queue
[
last
][
5
],
queue
[
last
-
1
][
5
])
// MLog.d(TAG, "__部位:右肩_____________竖直移动距离:$movedistance2")
val
movedistance3
=
AngleCalculateHelper
.
yDiff
(
queue
[
last
][
8
],
queue
[
last
-
1
][
8
])
// MLog.d(TAG, "__部位:左髋_____________竖直移动距离:$movedistance3")
val
movedistance4
=
AngleCalculateHelper
.
yDiff
(
queue
[
last
][
11
],
queue
[
last
-
1
][
11
])
if
(
movedistance1
>
0
&&
movedistance2
>
0
||
movedistance3
>
0
&&
movedistance4
>
0
)
{
isUp
=
false
}
override
fun
onCalInfo
(
calResult
:
Double
)
{
var
cal
=
calResult
if
(
java
.
lang
.
Double
.
isNaN
(
cal
)
||
java
.
lang
.
Double
.
isInfinite
(
cal
))
{
cal
=
0.0
}
runOnUiThread
{
textDebug3
?.
setText
(
"""
calResult:
${StringUtils.formatNum(cal, 1)}
"""
.
trimIndent
()
)
}
if
(
isUp
)
{
return
}
if
(
movedistance1
<
0
&&
abs
(
movedistance1
)
>
thresholdVal
&&
movedistance2
<
0
&&
abs
(
movedistance2
)
>
thresholdVal
||
movedistance3
<
0
&&
abs
(
movedistance3
)
>
thresholdVal
&&
movedistance4
<
0
&&
abs
(
movedistance4
)
>
thresholdVal
)
{
updateInfo
()
isUp
=
true
}
})
poseView
=
findViewById
(
R
.
id
.
pose_camera
)
poseView
?.
getRenderHelper
()
?.
setOnFrameListener
{
pointFS
->
Log
.
i
(
"ademo"
,
"on onFrame"
)
calFrameDelegate
.
onFrame
(
pointFS
)
}
}
...
...
@@ -191,57 +246,57 @@ class ActionCountActivity : Activity() {
}
// private val bodyConstants = HashMap<String, Double>()
private
val
pointChNames
=
HashMap
<
String
,
String
>()
fun
initInfo
()
{
// /** 头顶-脖子 高差 */
// bodyConstants["OH_NK_1"] = -65.36
// /** 左膝-左踝 高差*/
// bodyConstants["LK_LA_1"] = -76.64
// /** 右膝-右踝 高差 */
// bodyConstants["RK_RA_1"] = -69.72
// /** 左胯-左膝 高差 */
// bodyConstants["LP_LK_1"] = -75.49
// /** 右胯-右膝 高差 */
// bodyConstants["RP_RK_1"] = -82.85
// /** 左肩-右肩 水平*/
// bodyConstants["LS_RS_2"] = -80.90
// /** 左肩-右肩 连线*/
// bodyConstants["LS_RS_3"] = 80.91
pointChNames
[
"RK"
]
=
"右膝"
pointChNames
[
"LK"
]
=
"左膝"
pointChNames
[
"RA"
]
=
"右踝"
pointChNames
[
"LA"
]
=
"左踝"
pointChNames
[
"LW"
]
=
"左腕"
pointChNames
[
"RW"
]
=
"右腕"
pointChNames
[
"LE"
]
=
"左耳"
pointChNames
[
"RE"
]
=
"右耳"
pointChNames
[
"LS"
]
=
"左肩"
pointChNames
[
"RS"
]
=
"右肩"
pointChNames
[
"LL"
]
=
"左水平"
pointChNames
[
"RL"
]
=
"右水平"
pointChNames
[
"LP"
]
=
"左髋"
pointChNames
[
"RP"
]
=
"右髋"
pointChNames
[
"LEW"
]
=
"左肘"
pointChNames
[
"REW"
]
=
"右肘"
pointChNames
[
"OH"
]
=
"头顶"
pointChNames
[
"NK"
]
=
"脖子"
}
// private val pointChNames = HashMap<String, String>()
private
fun
transConstantsNameToCh
(
key
:
String
):
String
?
{
val
sb
=
StringBuilder
()
val
s
=
key
.
split
(
"_"
).
toTypedArray
()
sb
.
append
(
pointChNames
[
s
[
0
]]).
append
(
"_"
)
sb
.
append
(
pointChNames
[
s
[
1
]]).
append
(
"_"
)
if
(
"0"
==
s
[
2
])
{
sb
.
append
(
"角度"
)
}
else
if
(
"1"
==
s
[
2
])
{
sb
.
append
(
"高差"
)
}
else
if
(
"2"
==
s
[
2
])
{
sb
.
append
(
"水平差"
)
}
else
{
sb
.
append
(
"距离"
)
}
return
sb
.
toString
()
}
// fun initInfo() {
//// /** 头顶-脖子 高差 */
//// bodyConstants["OH_NK_1"] = -65.36
//// /** 左膝-左踝 高差*/
//// bodyConstants["LK_LA_1"] = -76.64
//// /** 右膝-右踝 高差 */
//// bodyConstants["RK_RA_1"] = -69.72
//// /** 左胯-左膝 高差 */
//// bodyConstants["LP_LK_1"] = -75.49
//// /** 右胯-右膝 高差 */
//// bodyConstants["RP_RK_1"] = -82.85
//// /** 左肩-右肩 水平*/
//// bodyConstants["LS_RS_2"] = -80.90
//// /** 左肩-右肩 连线*/
//// bodyConstants["LS_RS_3"] = 80.91
// pointChNames["RK"] = "右膝"
// pointChNames["LK"] = "左膝"
// pointChNames["RA"] = "右踝"
// pointChNames["LA"] = "左踝"
// pointChNames["LW"] = "左腕"
// pointChNames["RW"] = "右腕"
// pointChNames["LE"] = "左耳"
// pointChNames["RE"] = "右耳"
// pointChNames["LS"] = "左肩"
// pointChNames["RS"] = "右肩"
// pointChNames["LL"] = "左水平"
// pointChNames["RL"] = "右水平"
// pointChNames["LP"] = "左髋"
// pointChNames["RP"] = "右髋"
// pointChNames["LEW"] = "左肘"
// pointChNames["REW"] = "右肘"
// pointChNames["OH"] = "头顶"
// pointChNames["NK"] = "脖子"
// }
// private fun transConstantsNameToCh(key: String): String? {
// val sb = StringBuilder()
// val s = key.split("_").toTypedArray()
// sb.append(pointChNames[s[0]]).append("_")
// sb.append(pointChNames[s[1]]).append("_")
// if ("0" == s[2]) {
// sb.append("角度")
// } else if ("1" == s[2]) {
// sb.append("高差")
// } else if ("2" == s[2]) {
// sb.append("水平差")
// } else {
// sb.append("距离")
// }
// return sb.toString()
// }
}
\ No newline at end of file
app/src/main/res/raw/action_kaihetiao.json
View file @
13d1c0c1
...
...
@@ -16,23 +16,5 @@
"innerStandardLimitPrompt"
:
"完美"
,
"innerErrorLimitA2XPrompt"
:
""
,
"innerErrorLimitB2YPrompt"
:
"双臂伸直,举过头顶"
},
{
"conditionType"
:
"0"
,
"angleDifferenceLimit"
:
{
"standardAngleA"
:
"75"
,
"standardAngleB"
:
"0"
,
"errorAngleA2X"
:
"85"
,
"errorAngleB2Y"
:
null
,
"caculateUserAnglePoint"
:
[
"LP"
,
"LK"
,
"RL"
]
},
"positionDifferenceLimit"
:
null
,
"innerStandardLimitPrompt"
:
"完美"
,
"innerErrorLimitA2XPrompt"
:
"双腿左右尽量分开"
,
"innerErrorLimitB2YPrompt"
:
""
}
]
\ No newline at end of file
app/src/main/res/raw/gameinfo.json
View file @
13d1c0c1
...
...
@@ -16,23 +16,5 @@
"innerStandardLimitPrompt"
:
"完美"
,
"innerErrorLimitA2XPrompt"
:
""
,
"innerErrorLimitB2YPrompt"
:
"双臂伸直,举过头顶"
},
{
"conditionType"
:
"0"
,
"angleDifferenceLimit"
:
{
"standardAngleA"
:
"75"
,
"standardAngleB"
:
"0"
,
"errorAngleA2X"
:
"85"
,
"errorAngleB2Y"
:
null
,
"caculateUserAnglePoint"
:
[
"LP"
,
"LK"
,
"RL"
]
},
"positionDifferenceLimit"
:
null
,
"innerStandardLimitPrompt"
:
"完美"
,
"innerErrorLimitA2XPrompt"
:
"双腿左右尽量分开"
,
"innerErrorLimitB2YPrompt"
:
""
}
]
\ 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