androidandroid-cameraglsurfaceviewgrafika

How to switch front/back camera in Android by GLSurfaceView?


I have posted an issue to grafika, but it seems there is nobody to maintain the project now.

I want to use the CameraCaptureActivity which implemented by GLSurfaceView to switch front/back camera, as following:

public boolean switchCamera() {
    releaseCamera();
    mGLView.onPause();
    if (mReqCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) {
        mReqCameraId = Camera.CameraInfo.CAMERA_FACING_FRONT;
    } else {
        mReqCameraId = Camera.CameraInfo.CAMERA_FACING_BACK;
    }
    openCamera(mReqCameraId);

    mGLView.onResume();
    mGLView.queueEvent(new Runnable() {
        @Override
        public void run() {
            mRenderer.setCameraPreviewSize(mCameraPreviewWidth, mCameraPreviewHeight);
        }
    });
    return true;
}

It can work, but the FOV has been changed when I back to the camera which first time launched. It seems the frame has been clipped.

So where did i miss when switch the front-back camera?

Thanks.

PS: I have googled, but there is little information about Android Camera with GLSurfaceView.


Solution

  • As @fadden's comment, i remove the setRecordingHint(true), and it works fine.