Merge 605afe392c
into b899d17f18
This commit is contained in:
commit
f30ddc9ad0
|
@ -0,0 +1,65 @@
|
||||||
|
# Copyright 2020 The MediaPipe Authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
licenses(["notice"])
|
||||||
|
|
||||||
|
package(default_visibility = ["//visibility:private"])
|
||||||
|
|
||||||
|
cc_binary(
|
||||||
|
name = "libmediapipe_jni.so",
|
||||||
|
linkshared = 1,
|
||||||
|
linkstatic = 1,
|
||||||
|
deps = [
|
||||||
|
"//mediapipe/graphs/object_detection:mobile_calculators",
|
||||||
|
"//mediapipe/graphs/pose_tracking:pose_tracking_cpu_deps",
|
||||||
|
"//mediapipe/java/com/google/mediapipe/framework/jni:mediapipe_framework_jni",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "mediapipe_jni_lib",
|
||||||
|
srcs = [":libmediapipe_jni.so"],
|
||||||
|
alwayslink = 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
android_binary(
|
||||||
|
name = "posetrackingcpu",
|
||||||
|
srcs = glob(["*.java"]),
|
||||||
|
assets = [
|
||||||
|
"//mediapipe/graphs/pose_tracking:pose_tracking_cpu.binarypb",
|
||||||
|
"//mediapipe/modules/pose_landmark:pose_landmark_full_body.tflite",
|
||||||
|
"//mediapipe/modules/pose_detection:pose_detection.tflite",
|
||||||
|
],
|
||||||
|
assets_dir = "",
|
||||||
|
manifest = "//mediapipe/examples/android/src/java/com/google/mediapipe/apps/basic:AndroidManifest.xml",
|
||||||
|
manifest_values = {
|
||||||
|
"applicationId": "com.google.mediapipe.apps.posetrackingcpu",
|
||||||
|
"appName": "Pose Tracking CPU",
|
||||||
|
"mainActivity": ".MainActivity",
|
||||||
|
"cameraFacingFront": "False",
|
||||||
|
"binaryGraphName": "pose_tracking_cpu.binarypb",
|
||||||
|
"inputVideoStreamName": "input_video",
|
||||||
|
"outputVideoStreamName": "output_video",
|
||||||
|
"flipFramesVertically": "True",
|
||||||
|
"converterNumBuffers": "2",
|
||||||
|
},
|
||||||
|
multidex = "native",
|
||||||
|
deps = [
|
||||||
|
":mediapipe_jni_lib",
|
||||||
|
"//mediapipe/examples/android/src/java/com/google/mediapipe/apps/basic:basic_lib",
|
||||||
|
"//mediapipe/framework/formats:landmark_java_proto_lite",
|
||||||
|
"//mediapipe/java/com/google/mediapipe/framework:android_framework",
|
||||||
|
"@com_google_protobuf//:protobuf_javalite",
|
||||||
|
],
|
||||||
|
)
|
|
@ -0,0 +1,76 @@
|
||||||
|
// Copyright 2020 The MediaPipe Authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package com.google.mediapipe.apps.posetrackingcpu;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.google.mediapipe.formats.proto.LandmarkProto.NormalizedLandmark;
|
||||||
|
import com.google.mediapipe.formats.proto.LandmarkProto.NormalizedLandmarkList;
|
||||||
|
import com.google.mediapipe.framework.PacketGetter;
|
||||||
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
|
|
||||||
|
/** Main activity of MediaPipe pose tracking app. */
|
||||||
|
public class MainActivity extends com.google.mediapipe.apps.basic.MainActivity {
|
||||||
|
private static final String TAG = "MainActivity";
|
||||||
|
|
||||||
|
private static final String OUTPUT_LANDMARKS_STREAM_NAME = "pose_landmarks";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// To show verbose logging, run:
|
||||||
|
// adb shell setprop log.tag.MainActivity VERBOSE
|
||||||
|
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
||||||
|
processor.addPacketCallback(
|
||||||
|
OUTPUT_LANDMARKS_STREAM_NAME,
|
||||||
|
(packet) -> {
|
||||||
|
Log.v(TAG, "Received pose landmarks packet.");
|
||||||
|
try {
|
||||||
|
NormalizedLandmarkList poseLandmarks =
|
||||||
|
PacketGetter.getProto(packet, NormalizedLandmarkList.class);
|
||||||
|
Log.v(
|
||||||
|
TAG,
|
||||||
|
"[TS:"
|
||||||
|
+ packet.getTimestamp()
|
||||||
|
+ "] "
|
||||||
|
+ getPoseLandmarksDebugString(poseLandmarks));
|
||||||
|
} catch (InvalidProtocolBufferException exception) {
|
||||||
|
Log.e(TAG, "Failed to get proto.", exception);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getPoseLandmarksDebugString(NormalizedLandmarkList poseLandmarks) {
|
||||||
|
String poseLandmarkStr = "Pose landmarks: " + poseLandmarks.getLandmarkCount() + "\n";
|
||||||
|
int landmarkIndex = 0;
|
||||||
|
for (NormalizedLandmark landmark : poseLandmarks.getLandmarkList()) {
|
||||||
|
poseLandmarkStr +=
|
||||||
|
"\tLandmark ["
|
||||||
|
+ landmarkIndex
|
||||||
|
+ "]: ("
|
||||||
|
+ landmark.getX()
|
||||||
|
+ ", "
|
||||||
|
+ landmark.getY()
|
||||||
|
+ ", "
|
||||||
|
+ landmark.getZ()
|
||||||
|
+ ")\n";
|
||||||
|
++landmarkIndex;
|
||||||
|
}
|
||||||
|
return poseLandmarkStr;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,18 @@
|
||||||
# CPU buffer. (ImageFrame)
|
# CPU buffer. (ImageFrame)
|
||||||
input_stream: "input_video"
|
input_stream: "input_video"
|
||||||
|
|
||||||
|
|
||||||
|
# Transfers the input image from GPU to CPU memory for the purpose of
|
||||||
|
# demonstrating a CPU-based pipeline. Note that the input image on GPU has the
|
||||||
|
# origin defined at the bottom-left corner (OpenGL convention). As a result,
|
||||||
|
# the transferred image on CPU also shares the same representation.
|
||||||
|
node: {
|
||||||
|
calculator: "GpuBufferToImageFrameCalculator"
|
||||||
|
input_stream: "input_video"
|
||||||
|
output_stream: "input_video_cpu"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Output image with rendered results. (ImageFrame)
|
# Output image with rendered results. (ImageFrame)
|
||||||
output_stream: "output_video"
|
output_stream: "output_video"
|
||||||
# Pose landmarks. (NormalizedLandmarkList)
|
# Pose landmarks. (NormalizedLandmarkList)
|
||||||
|
@ -20,7 +32,7 @@ output_stream: "pose_landmarks"
|
||||||
# subsequent nodes are still busy processing previous inputs.
|
# subsequent nodes are still busy processing previous inputs.
|
||||||
node {
|
node {
|
||||||
calculator: "FlowLimiterCalculator"
|
calculator: "FlowLimiterCalculator"
|
||||||
input_stream: "input_video"
|
input_stream: "input_video_cpu"
|
||||||
input_stream: "FINISHED:output_video"
|
input_stream: "FINISHED:output_video"
|
||||||
input_stream_info: {
|
input_stream_info: {
|
||||||
tag_index: "FINISHED"
|
tag_index: "FINISHED"
|
||||||
|
@ -45,5 +57,14 @@ node {
|
||||||
input_stream: "LANDMARKS:pose_landmarks"
|
input_stream: "LANDMARKS:pose_landmarks"
|
||||||
input_stream: "ROI:roi_from_landmarks"
|
input_stream: "ROI:roi_from_landmarks"
|
||||||
input_stream: "DETECTION:pose_detection"
|
input_stream: "DETECTION:pose_detection"
|
||||||
output_stream: "IMAGE:output_video"
|
output_stream: "IMAGE:output_video_cpu"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Transfers the annotated image from CPU back to GPU memory, to be sent out of
|
||||||
|
# the graph.
|
||||||
|
node: {
|
||||||
|
calculator: "ImageFrameToGpuBufferCalculator"
|
||||||
|
input_stream: "output_video_cpu"
|
||||||
|
output_stream: "output_video"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user