Git Product home page Git Product logo

Comments (8)

wakengine avatar wakengine commented on August 26, 2024

Did you trigger af manually or set focus mode as CONTINUOUS_PICTURE?

from android-camera2basic.

gilles-yvetot avatar gilles-yvetot commented on August 26, 2024

I set focus mode to CONTINUOUS_PICTURE

from android-camera2basic.

wakengine avatar wakengine commented on August 26, 2024

Then maybe your focus area is too big, you can try another reasonable setting.

from android-camera2basic.

gilles-yvetot avatar gilles-yvetot commented on August 26, 2024

I have tried without setting any focus area and it does not work. It looks like it depends on the device, I have tested on a Motoroall Moto E, it is working, but it does NOT work on a Samsung S5.

from android-camera2basic.

gilles-yvetot avatar gilles-yvetot commented on August 26, 2024

Actually even the basic projet does not work on Samsung S5, I meant the continuous focus mode...

from android-camera2basic.

gilles-yvetot avatar gilles-yvetot commented on August 26, 2024

Hello @yaraki, did you have time to check this out? That's my priority now so we can even work together on that?

from android-camera2basic.

yudikarma avatar yudikarma commented on August 26, 2024

this working to me

`public void handleFocus(MotionEvent event) {
int pointerId = event.getPointerId(0);
int pointerIndex = event.findPointerIndex(pointerId);
// Get the pointer's current position
float x = event.getX(pointerIndex);
float y = event.getY(pointerIndex);

    Rect touchRect = new Rect(
            (int) (x - 100),
            (int) (y - 100),
            (int) (x + 100),
            (int) (y + 100) );


    if (mCameraId == null) return;
    CameraManager cm = (CameraManager)this.getSystemService(Context.CAMERA_SERVICE);
    CameraCharacteristics cc = null;
    try {
        cc = cm.getCameraCharacteristics(mCameraId);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }


    MeteringRectangle focusArea = new MeteringRectangle(touchRect,MeteringRectangle.METERING_WEIGHT_DONT_CARE);
    mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
    try {
        mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback,
                mBackgroundHandler);
        // After this, the camera will go back to the normal state of preview.
        mState = STATE_PREVIEW;
    } catch (CameraAccessException e){
        // log
    }

   /* if (isMeteringAreaAESupported(cc)) {
        *//*mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS,
                new MeteringRectangle[]{focusArea});*//*
    }
    if (isMeteringAreaAFSupported(cc)) {
        *//*mPreviewRequestBuilder
                .set(CaptureRequest.CONTROL_AF_REGIONS, new MeteringRectangle[]{focusArea});
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                CaptureRequest.CONTROL_AF_MODE_AUTO);*//*
    }*/
    mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS,
            new MeteringRectangle[]{focusArea});
    mPreviewRequestBuilder
            .set(CaptureRequest.CONTROL_AF_REGIONS, new MeteringRectangle[]{focusArea});
    mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
            CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
    mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
            CameraMetadata.CONTROL_AF_TRIGGER_START);
    mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
            CameraMetadata.CONTROL_AE_PRECAPTURE_TRIGGER_START);
    try {
        mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), mCaptureCallback,
                mBackgroundHandler);
       /* mManualFocusEngaged = true;*/
    } catch (CameraAccessException e) {
        // error handling
    }
}`

from android-camera2basic.

gilles-yvetot avatar gilles-yvetot commented on August 26, 2024

@yudikarma, it is a bit late for me, I am not working for the same company anymore but I appreciate you took the time to reply, I am sure it will help other people.

from android-camera2basic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.