added lindera api demonstraction in example app
This commit is contained in:
parent
7604bb2fd7
commit
7f8ec5da32
|
@ -7,7 +7,7 @@ android {
|
|||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.google.mediapipe.apps.posetracking_camera"
|
||||
applicationId "com.google.mediapipe.apps.posetracking_lindera"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
POSE_TRACKING_OUTPUT_DIR=bazel-bin/mediapipe/java/com/google/mediapipe/solutions/posetracking
|
||||
GRADLE_LIBS_DIR=mediapipe/examples/android/solutions/posetracking-camera/libs
|
||||
GRADLE_LIBS_DIR=mediapipe/examples/android/solutions/posetracking-lindera/libs
|
||||
#
|
||||
bazel build -c opt --strip=ALWAYS\
|
||||
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
|
||||
|
@ -18,9 +18,11 @@ bazel build -c opt --strip=ALWAYS\
|
|||
//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-landmark.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-detection.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-graph.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/lindera:copperlabs-lindera.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutioncore:copperlabs-mediapipe
|
||||
|
||||
|
||||
|
||||
mkdir $GRADLE_LIBS_DIR
|
||||
rm -f $GRADLE_LIBS_DIR/copperlabs-*.aar
|
||||
|
||||
|
@ -28,5 +30,6 @@ rm -f $GRADLE_LIBS_DIR/copperlabs-*.aar
|
|||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-detection.aar $GRADLE_LIBS_DIR
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-graph.aar $GRADLE_LIBS_DIR
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-landmark.aar $GRADLE_LIBS_DIR
|
||||
\cp bazel-bin/mediapipe/java/com/google/mediapipe/solutions/lindera/copperlabs-lindera.aar $GRADLE_LIBS_DIR
|
||||
\cp bazel-bin/mediapipe/java/com/google/mediapipe/solutioncore/copperlabs-mediapipe.aar $GRADLE_LIBS_DIR
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.widget.FrameLayout;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.google.mediapipe.solutions.lindera.CameraRotation;
|
||||
import com.google.mediapipe.solutions.lindera.ComputerVisionPlugin;
|
||||
import com.google.mediapipe.solutions.lindera.Lindera;
|
||||
|
||||
|
@ -35,6 +36,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
private Lindera lindera;
|
||||
private ComputerVisionPlugin plugin;
|
||||
private boolean isLinderaInitialized = false;
|
||||
private boolean isDetectionStarted = false;
|
||||
// Live camera demo UI and camera components.
|
||||
|
||||
|
||||
|
@ -50,7 +53,10 @@ public class MainActivity extends AppCompatActivity {
|
|||
plugin = new ComputerVisionPluginImpl();
|
||||
lindera = new Lindera(plugin);
|
||||
List<String> cameras = lindera.getAvailableCameras();
|
||||
lindera.setCamera("BACK");
|
||||
// FRONT or BACK
|
||||
lindera.setCamera("FRONT");
|
||||
lindera.setCameraRotation(CameraRotation.AUTOMATIC);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,9 +70,28 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
startCameraButton.setOnClickListener(
|
||||
v -> {
|
||||
startCameraButton.setVisibility(View.GONE);
|
||||
// startCameraButton.setVisibility(View.GONE);
|
||||
if (!isLinderaInitialized) {
|
||||
lindera.initialize(frameLayout, MainActivity.this);
|
||||
isLinderaInitialized = true;
|
||||
startCameraButton.setText("STOP CAMERA");
|
||||
|
||||
} else {
|
||||
|
||||
if (isDetectionStarted) {
|
||||
startCameraButton.setText(R.string.start_camera);
|
||||
|
||||
|
||||
lindera.stopDetection();
|
||||
} else {
|
||||
lindera.startDetection();
|
||||
startCameraButton.setText("STOP CAMERA");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
isDetectionStarted = !isDetectionStarted;
|
||||
|
||||
lindera.initialize(frameLayout, MainActivity.this);
|
||||
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user