added rotation support
This commit is contained in:
parent
9150dd57cc
commit
a31b61f15a
|
@ -21,6 +21,7 @@ import android.os.Bundle;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Surface;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
@ -44,7 +45,7 @@ import java.io.InputStream;
|
||||||
/** Main activity of MediaPipe Face Detection app. */
|
/** Main activity of MediaPipe Face Detection app. */
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
private static final String TAG = "MainActivity";
|
private static final String TAG = "MainActivity";
|
||||||
|
private static int rotation = Surface.ROTATION_0;
|
||||||
private PoseTracking poseTracking;
|
private PoseTracking poseTracking;
|
||||||
|
|
||||||
private enum InputSource {
|
private enum InputSource {
|
||||||
|
@ -280,6 +281,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
if (inputSource == InputSource.CAMERA) {
|
if (inputSource == InputSource.CAMERA) {
|
||||||
cameraInput = new CameraInput(this);
|
cameraInput = new CameraInput(this);
|
||||||
|
|
||||||
cameraInput.setNewFrameListener(textureFrame -> poseTracking.send(textureFrame));
|
cameraInput.setNewFrameListener(textureFrame -> poseTracking.send(textureFrame));
|
||||||
} else if (inputSource == InputSource.VIDEO) {
|
} else if (inputSource == InputSource.VIDEO) {
|
||||||
videoInput = new VideoInput(this);
|
videoInput = new VideoInput(this);
|
||||||
|
@ -315,6 +317,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startCamera() {
|
private void startCamera() {
|
||||||
|
cameraInput.getConverter(poseTracking.getGlContext()).setRotation(rotation);
|
||||||
cameraInput.start(
|
cameraInput.start(
|
||||||
this,
|
this,
|
||||||
poseTracking.getGlContext(),
|
poseTracking.getGlContext(),
|
||||||
|
@ -346,7 +349,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LandmarkProto.Landmark exampleLandmark = result.multiPoseLandmarks().get(0);
|
LandmarkProto.Landmark exampleLandmark = result.multiPoseLandmarks().get(0);
|
||||||
Log.d(
|
Log.i(
|
||||||
TAG,
|
TAG,
|
||||||
String.format(
|
String.format(
|
||||||
"Pose Landmark Landmark at index 0: x=%f, y=%f, z=%f",
|
"Pose Landmark Landmark at index 0: x=%f, y=%f, z=%f",
|
||||||
|
|
|
@ -57,6 +57,13 @@ public class CameraInput {
|
||||||
PermissionHelper.checkAndRequestCameraPermissions(activity);
|
PermissionHelper.checkAndRequestCameraPermissions(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ExternalTextureConverter getConverter(EGLContext eglContext){
|
||||||
|
if (converter == null) {
|
||||||
|
converter = new ExternalTextureConverter(eglContext, 2);
|
||||||
|
}
|
||||||
|
return converter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a callback to be invoked when new frames available.
|
* Sets a callback to be invoked when new frames available.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user