Sirop4ik
Sirop4ik

Reputation: 5243

Is there an equivalent to the camera 2 API method camera.autoFocus() in the camera API?

In first camera i have such method

private void takePicture()
{
    camera.autoFocus(new Camera.AutoFocusCallback() {

        @Override
        public void onAutoFocus(boolean success, Camera camera) {
            camera.takePicture(shutterCallback, pictureCallback_RAW, pictureCallback_JPEG);
        }
    });
}

And it is convinient , when user take a picture , app is trying focused and than take a picture...

Question is : how a can implement in camera2API some callback or another way to wait until camera take a focus and that take a picture?

Upvotes: 1

Views: 521

Answers (1)

Andrii Omelchenko
Andrii Omelchenko

Reputation: 13343

Try this sample project from Google (or just Camera2BasicFragment). In general You should request focus, than determine "focus lock" state in CameraCaptureSession.CaptureCallback than capture image and finally request for unlock focus.

Upvotes: 1

Related Questions