From a11e684a7b53b2288bd2435ed63bc73bcd82db22 Mon Sep 17 00:00:00 2001 From: o__-xpf-__o <2689129162@qq.com> Date: Sun, 25 May 2025 17:41:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E7=85=A7=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../examples/poseestimation/ml/PoseNet.kt | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/android/app/src/main/java/org/tensorflow/lite/examples/poseestimation/ml/PoseNet.kt b/android/app/src/main/java/org/tensorflow/lite/examples/poseestimation/ml/PoseNet.kt index 92a7c49..868320f 100644 --- a/android/app/src/main/java/org/tensorflow/lite/examples/poseestimation/ml/PoseNet.kt +++ b/android/app/src/main/java/org/tensorflow/lite/examples/poseestimation/ml/PoseNet.kt @@ -204,36 +204,14 @@ class PoseNet(private val interpreter: Interpreter, private var gpuDelegate: Gpu ) totalScore += confidenceScores[idx] } - - // 在此部分中添加角度数据和合格率数据 - // 遍历 keyPoints - keypointList.forEach { keypoint -> - // 获取当前关键点的位置 - val x = keypoint.coordinate.x - val y = keypoint.coordinate.y - - // 假设我们计算胸部与左右肩膀之间的角度(这里只是示例,具体取决于你的模型) - if (keypoint.bodyPart == BodyPart.LEFT_SHOULDER || keypoint.bodyPart == BodyPart.RIGHT_SHOULDER) { - // 获取左肩和右肩的坐标 - val leftShoulder = keypointList.first { it.bodyPart == BodyPart.LEFT_SHOULDER } - val rightShoulder = keypointList.first { it.bodyPart == BodyPart.RIGHT_SHOULDER } - - // 计算肩膀角度 - val angle = calculateAngle( - leftShoulder.coordinate.x, - leftShoulder.coordinate.y, - rightShoulder.coordinate.x, - rightShoulder.coordinate.y - ) - - } - - // 添加合格率数据 - } + //计算并得到关键点之间的角度关系 + val keypoint = KeypointAngles() + keypoint.csAngles(keypointList.toList()) // 返回一个包含关键点和总分数的Person对象 return Person(keyPoints = keypointList.toList(), score = totalScore / numKeypoints) } + class KeypointAngles { // 用来存储角度的列表 val angles = mutableListOf() @@ -322,9 +300,6 @@ class PoseNet(private val interpreter: Interpreter, private var gpuDelegate: Gpu } } - - - // 返回上一次推理的时间 override fun lastInferenceTimeNanos(): Long = lastInferenceTimeNanos