File tree Expand file tree Collapse file tree
lite/examples/posenet/android/app/src/main/java/org/tensorflow/lite/examples/posenet Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ package org.tensorflow.lite.examples.posenet
1717
1818import android.graphics.Bitmap
1919import android.graphics.Canvas
20+ import android.graphics.Color
21+ import android.graphics.Paint
2022import android.graphics.drawable.Drawable
2123import android.os.Bundle
2224import android.support.v4.content.res.ResourcesCompat
@@ -66,5 +68,21 @@ class MainActivity : AppCompatActivity() {
6668 interpreter = Interpreter (loadModelFile(" posenet_model.tflite" ))
6769 val posenet = Posenet ()
6870 val person = posenet.estimateSinglePose(interpreter!! , imageBitmap)
71+
72+ // Draw the keypoints over the image.
73+ val red = Paint ()
74+ red.setColor(Color .RED )
75+ val size = 2.0f
76+
77+ val mutableBitmap = imageBitmap.copy(Bitmap .Config .ARGB_8888 , true )
78+ val canvas = Canvas (mutableBitmap)
79+ for (i in 0 until person.keyPoints.size) {
80+ canvas.drawCircle(
81+ person.keyPoints[i].position.x.toFloat(),
82+ person.keyPoints[i].position.y.toFloat(), size, red
83+ )
84+ }
85+ sampleImageView.setAdjustViewBounds(true )
86+ sampleImageView.setImageBitmap(mutableBitmap)
6987 }
7088}
You can’t perform that action at this time.
0 commit comments