Smoother skeleton
This commit is contained in:
@@ -8,7 +8,6 @@ import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.example.jnicpp.R
|
||||
import com.google.mlkit.vision.pose.Pose
|
||||
|
||||
/**
|
||||
* Draws the 33 ML Kit pose landmarks and connecting skeleton lines on top of
|
||||
@@ -43,7 +42,7 @@ class PoseOverlayView @JvmOverloads constructor(
|
||||
setShadowLayer(4f, 0f, 0f, ContextCompat.getColor(context, R.color.black))
|
||||
}
|
||||
|
||||
private var pose: Pose? = null
|
||||
private var landmarks: Map<Int, SmoothedLandmark>? = null
|
||||
private var angles: PoseAngles? = null
|
||||
private var isFrontCamera = false
|
||||
|
||||
@@ -58,7 +57,7 @@ class PoseOverlayView @JvmOverloads constructor(
|
||||
|
||||
/** Called from the main thread with the latest analyzer result, or null to clear. */
|
||||
fun update(frame: PoseAnalyzer.PoseFrameResult?) {
|
||||
pose = frame?.pose
|
||||
landmarks = frame?.landmarks
|
||||
angles = frame?.angles
|
||||
if (frame != null) {
|
||||
isFrontCamera = frame.isFrontCamera
|
||||
@@ -71,7 +70,7 @@ class PoseOverlayView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
pose = null
|
||||
landmarks = null
|
||||
angles = null
|
||||
invalidate()
|
||||
}
|
||||
@@ -96,8 +95,8 @@ class PoseOverlayView @JvmOverloads constructor(
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
super.onDraw(canvas)
|
||||
val currentPose = pose ?: return
|
||||
PoseSkeletonRenderer.draw(canvas, currentPose, transform, bonePaint, jointPaint)
|
||||
angles?.let { PoseSkeletonRenderer.drawAngleLabels(canvas, currentPose, it, transform, anglePaint) }
|
||||
val currentLandmarks = landmarks ?: return
|
||||
PoseSkeletonRenderer.draw(canvas, currentLandmarks, transform, bonePaint, jointPaint)
|
||||
angles?.let { PoseSkeletonRenderer.drawAngleLabels(canvas, currentLandmarks, it, transform, anglePaint) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user