0

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.

fadden
  • 51,356
  • 5
  • 116
  • 166
Jerikc XIONG
  • 3,517
  • 5
  • 42
  • 71
  • @fadden Could you please help me solve the problem? Thanks. – Jerikc XIONG Jul 13 '15 at 10:47
  • 2
    I commented on the grafika issue. It sounds a lot like this, from two weeks back: http://stackoverflow.com/questions/31114191/field-of-camera-preview-is-smaller-if-i-use-the-way-of-preview-in-grifikas-cont . Basically, the FOV seems to change when you call `setRecordingHint(true)`. – fadden Jul 13 '15 at 19:49
  • 1
    FWIW, you'd be better off with SurfaceView. GLSurfaceView is just a wrapper around SurfaceView that adds EGL context setup and thread management. Since you can't render on a SurfaceView at the same time that it's receiving the camera preview, there's not much reason to use it. – fadden Jul 13 '15 at 19:51
  • Are you sure the parameters *mCameraPreviewWidth, mCameraPreviewHeight* did not change after you flipped back and forward? One simple reason could be, if you start with `CAMERA_FACING_BACK` and choose the best preview size, then to `CAMERA_FACING_FRONT` with limited preview size, then back to `CAMERA_FACING_BACK` (pun intended) keeping the supported, but less than optimal preview size inherited form front facing camera. – Alex Cohn Jul 13 '15 at 21:02
  • @fadden After a struggle, I finally found you are right. The `setRecordingHint(true)` have a side effect on it. The real preview size is not the desired preview size while `switchCamera` , but the ratio is from desired preview size. But if i simply remove the `setRecordingHint(true)`, is there some side effects on it ? – Jerikc XIONG Jul 14 '15 at 04:08
  • @JerikcXIONG: `setRecordingHint(true)` can have a significant impact on the frame rate when recording video. It varies from device to device. – fadden Jul 14 '15 at 15:24

1 Answers1

0

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

Jerikc XIONG
  • 3,517
  • 5
  • 42
  • 71