Skip to content

Commit

Permalink
List of included changes imported by Copybara:
Browse files Browse the repository at this point in the history
  - Add pose detection screenshoot to Android quickstart README page
  - Use the kotlin base class for PoseDetectorProcessor.kt and SegmenterProcessor.kt

PiperOrigin-RevId: 360283708
Change-Id: Ia4019d02527ea0f44225ac163f8eea8ab695ed9d
  • Loading branch information
Google ML Kit authored and Chengji Yan committed Mar 1, 2021
1 parent ae9032e commit caf19a0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion android/vision-quickstart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Features that are included in this Quickstart app:
* [Pose Detection](https://developers.google.com/ml-kit/vision/pose-detection/android) - Detect the position of the human body in real time.
* [Selfie Segmentation](https://developers.google.com/ml-kit/vision/selfie-segmentation/android) - Segment people from the background in real time.

<img src="../screenshots/quickstart-picker.png" width="256"/> <img src="../screenshots/quickstart-image-labeling.png" width="256"/> <img src="../screenshots/quickstart-object-detection.png" width="256"/>
<img src="../screenshots/quickstart-picker.png" width="256"/> <img src="../screenshots/quickstart-image-labeling.png" width="256"/> <img src="../screenshots/quickstart-object-detection.png" width="256"/> <img src="../screenshots/quickstart-pose-detection.png" width="256"/>

## Getting Started

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import android.util.Log
import com.google.android.gms.tasks.Task
import com.google.mlkit.vision.common.InputImage
import com.google.mlkit.vision.demo.GraphicOverlay
import com.google.mlkit.vision.demo.java.VisionProcessorBase
import com.google.mlkit.vision.demo.java.posedetector.classification.PoseClassifierProcessor
import com.google.mlkit.vision.demo.kotlin.VisionProcessorBase
import com.google.mlkit.vision.pose.Pose
import com.google.mlkit.vision.pose.PoseDetection
import com.google.mlkit.vision.pose.PoseDetector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,32 +114,32 @@ class PoseGraphic internal constructor(
val leftFootIndex = pose.getPoseLandmark(PoseLandmark.LEFT_FOOT_INDEX)
val rightFootIndex = pose.getPoseLandmark(PoseLandmark.RIGHT_FOOT_INDEX)

drawLine(canvas, leftShoulder!!, rightShoulder!!, whitePaint)
drawLine(canvas, leftHip!!, rightHip!!, whitePaint)
drawLine(canvas, leftShoulder, rightShoulder, whitePaint)
drawLine(canvas, leftHip, rightHip, whitePaint)
// Left body
drawLine(canvas, leftShoulder, leftElbow!!, leftPaint)
drawLine(canvas, leftElbow, leftWrist!!, leftPaint)
drawLine(canvas, leftShoulder, leftElbow, leftPaint)
drawLine(canvas, leftElbow, leftWrist, leftPaint)
drawLine(canvas, leftShoulder, leftHip, leftPaint)
drawLine(canvas, leftHip, leftKnee!!, leftPaint)
drawLine(canvas, leftKnee, leftAnkle!!, leftPaint)
drawLine(canvas, leftWrist, leftThumb!!, leftPaint)
drawLine(canvas, leftWrist, leftPinky!!, leftPaint)
drawLine(canvas, leftWrist, leftIndex!!, leftPaint)
drawLine(canvas, leftIndex, leftPinky!!, leftPaint)
drawLine(canvas, leftAnkle, leftHeel!!, leftPaint)
drawLine(canvas, leftHeel, leftFootIndex!!, leftPaint)
drawLine(canvas, leftHip, leftKnee, leftPaint)
drawLine(canvas, leftKnee, leftAnkle, leftPaint)
drawLine(canvas, leftWrist, leftThumb, leftPaint)
drawLine(canvas, leftWrist, leftPinky, leftPaint)
drawLine(canvas, leftWrist, leftIndex, leftPaint)
drawLine(canvas, leftIndex, leftPinky, leftPaint)
drawLine(canvas, leftAnkle, leftHeel, leftPaint)
drawLine(canvas, leftHeel, leftFootIndex, leftPaint)
// Right body
drawLine(canvas, rightShoulder, rightElbow!!, rightPaint)
drawLine(canvas, rightElbow, rightWrist!!, rightPaint)
drawLine(canvas, rightShoulder, rightElbow, rightPaint)
drawLine(canvas, rightElbow, rightWrist, rightPaint)
drawLine(canvas, rightShoulder, rightHip, rightPaint)
drawLine(canvas, rightHip, rightKnee!!, rightPaint)
drawLine(canvas, rightKnee, rightAnkle!!, rightPaint)
drawLine(canvas, rightWrist, rightThumb!!, rightPaint)
drawLine(canvas, rightWrist, rightPinky!!, rightPaint)
drawLine(canvas, rightWrist, rightIndex!!, rightPaint)
drawLine(canvas, rightIndex, rightPinky!!, rightPaint)
drawLine(canvas, rightAnkle, rightHeel!!, rightPaint)
drawLine(canvas, rightHeel, rightFootIndex!!, rightPaint)
drawLine(canvas, rightHip, rightKnee, rightPaint)
drawLine(canvas, rightKnee, rightAnkle, rightPaint)
drawLine(canvas, rightWrist, rightThumb, rightPaint)
drawLine(canvas, rightWrist, rightPinky, rightPaint)
drawLine(canvas, rightWrist, rightIndex, rightPaint)
drawLine(canvas, rightIndex, rightPinky, rightPaint)
drawLine(canvas, rightAnkle, rightHeel, rightPaint)
drawLine(canvas, rightHeel, rightFootIndex, rightPaint)

// Draw inFrameLikelihood for all points
if (showInFrameLikelihood) {
Expand All @@ -161,15 +161,15 @@ class PoseGraphic internal constructor(

internal fun drawLine(
canvas: Canvas,
startLandmark: PoseLandmark,
endLandmark: PoseLandmark,
startLandmark: PoseLandmark?,
endLandmark: PoseLandmark?,
paint: Paint
) {
// When visualizeZ is true, sets up the paint to draw body line in different colors based on
// their z values.
if (visualizeZ) {
val start = startLandmark.position3D
val end = endLandmark.position3D
val start = startLandmark!!.position3D
val end = endLandmark!!.position3D

// Gets the range of z value.
val zLowerBoundInScreenPixel: Float
Expand Down Expand Up @@ -213,8 +213,8 @@ class PoseGraphic internal constructor(
paint
)
} else {
val start = startLandmark.position
val end = endLandmark.position
val start = startLandmark!!.position
val end = endLandmark!!.position
canvas.drawLine(
translateX(start.x), translateY(start.y), translateX(end.x), translateY(end.y), paint
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import android.util.Log
import com.google.android.gms.tasks.Task
import com.google.mlkit.vision.common.InputImage
import com.google.mlkit.vision.demo.GraphicOverlay
import com.google.mlkit.vision.demo.java.VisionProcessorBase
import com.google.mlkit.vision.demo.kotlin.VisionProcessorBase
import com.google.mlkit.vision.demo.preference.PreferenceUtils
import com.google.mlkit.vision.segmentation.Segmentation
import com.google.mlkit.vision.segmentation.SegmentationMask
Expand Down Expand Up @@ -55,7 +55,7 @@ class SegmenterProcessor :
Log.d(TAG, "SegmenterProcessor created with option: " + options)
}

override fun detectInImage(image: InputImage): Task<SegmentationMask?>? {
override fun detectInImage(image: InputImage): Task<SegmentationMask> {
return segmenter.process(image)
}

Expand Down

0 comments on commit caf19a0

Please sign in to comment.