Skip to content

Commit dc5a8f1

Browse files
committed
fix initial portrait orientation
1 parent 0142554 commit dc5a8f1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

FaceTracker/app/src/main/java/com/google/android/gms/samples/vision/face/facetracker/FaceTrackerActivity.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.content.Context;
2323
import android.content.DialogInterface;
2424
import android.content.pm.PackageManager;
25+
import android.content.res.Configuration;
2526
import android.graphics.Bitmap;
2627
import android.graphics.BitmapFactory;
2728
import android.hardware.Camera;
@@ -218,13 +219,23 @@ private void createCameraSource() {
218219
// }
219220

220221
calcCameraFrameSize();
222+
223+
int w = mBackCamWidth;
224+
int h = mBackCamHeight;
225+
int orientation = context.getResources().getConfiguration().orientation;
226+
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
227+
w = mBackCamHeight;
228+
h = mBackCamWidth;
229+
}
230+
221231
mCameraSource = new CameraSource.Builder(context, customDetector)
222-
.setRequestedPreviewSize(mBackCamWidth, mBackCamHeight)
232+
.setRequestedPreviewSize(w, h)
223233
.setFacing(CameraSource.CAMERA_FACING_BACK)
224234
.setAutoFocusEnabled(true)
225235
.setRequestedFps(10)
226236
.build();
227237

238+
228239
// mBtnDetect.setOnClickListener(new View.OnClickListener() {
229240
// @Override
230241
// public void onClick(View v) {

0 commit comments

Comments
 (0)