Samsung s4 zoom does not support smooth zoom isSmo

2019-02-19 17:31发布

问题:

I've tried to handle ZoomIn/ZoomOut at 's4 zoom' device in my camera record application. Because it does support only regular zoom, i.e parameters.isZoomSupported()==true, parameters.isSmoothZoomSupported()==false, I have used parameters.setZoom(mZoomVal); mCamera.setParameters(parameters); as usual. Problem is Zoom is jerky, noisy and not smooth. Does anybody know how to handle Zoom speed in 's4 zoom' as like it was done in Samsung camera app?

public boolean onKeyDown(int keyCode, KeyEvent event) {
    Log.v("onKeyDown keyCode="+keyCode+" event="+event.toString());

    boolean handled = false;
    switch(keyCode){
    case KeyEvent.KEYCODE_FOCUS:
        setAutoFocus();
        handled = true;
        break;
    case KeyEvent.KEYCODE_CAMERA:

        if(event.getRepeatCount() == 0){
            if (isRec()) {
                stopRec(1, 0);
            } else {
                startRec();
            }
        }

        handled = true;
        break;
    case 256: //KeyEvent.KEYCODE_CAMERA_ZOOM_RING_MOVE:
        handled = true;
        break;
    case 261: //KeyEvent.KEYCODE_CAMERA_ZOOM_RING_SPEED2
        handled = true;
        break;
    case KeyEvent.KEYCODE_ZOOM_IN:
        setZoomIn();
        //AutoFocus();
        handled = true;
        break;
    case KeyEvent.KEYCODE_ZOOM_OUT:
        setZoomOut();
        //AutoFocus();
        handled = true;
        break;
    }

    if(handled)
        Log.v("onKeyDown HANDLED!");
    else
        return super.onKeyDown(keyCode, event);

    return handled;
}
public int setZoomIn(){
    if(mCamera == null){
        return 0;
    }

    Parameters parameters = mCamera.getParameters();
    List<Integer> zoom_list = parameters.getZoomRatios();
    if(mZoomVal >= mZoomMax)
        return zoom_list.get(mZoomMax);

    /*
    if(isAutoFocusing){
        mCamera.cancelAutoFocus();
        isAutoFocusing = false;
    }*/


    mZoomVal++;
    isFocused = false;

    parameters.setZoom(mZoomVal);
    mCamera.setParameters(parameters);

    mZoomVal = parameters.getZoom();

    return zoom_list.get(mZoomVal);
}

public int setZoomOut(){
    if(mCamera == null){
        return 0;
    }

    Parameters parameters = mCamera.getParameters();
    List<Integer> zoom_list = parameters.getZoomRatios();
    if(mZoomVal <= 0)
        return zoom_list.get(0);

    /*
    if(isAutoFocusing){
        mCamera.cancelAutoFocus();
        isAutoFocusing = false;
    }*/


    mZoomVal--;
    isFocused = false;

    parameters.setZoom(mZoomVal);
    mCamera.setParameters(parameters);

    mZoomVal = parameters.getZoom();

    return zoom_list.get(mZoomVal);
}

public void setAutoFocus(){
    if(mCamera == null){
        return;
    }

    if(isFocused)
        return;

    if(isAutoFocusing){
        mCamera.cancelAutoFocus();
        isAutoFocusing = false;
    }

    isAutoFocusing = true;
    mCamera.autoFocus(new Camera.AutoFocusCallback() {

        @Override
        public void onAutoFocus(boolean success, Camera camera) {
            Log.v("onAutoFocus success="+success);
            isAutoFocusing = false;
            isFocused = success;
        }
    });

}

回答1:

I have already found solution for Smooth control of Shutter lens on Samsung S4 Zoom device. Set device in smart mode: parameters.set("mode", "smart-auto");

For Zoom In start: parameters.set("zoom-action", "optical-tele-start");

For Zoom Out start: parameters.set("zoom-action", "optical-wide-start");

For Zoom action stop: parameters.set("zoom-action", "zoom-stop");

Shutter speed: parameters.set("zoom-speed", 1); //1,2,...

Don't forget save parameters in the Camera instance mCamera.setParameters(parameters);

This works fine in my device, shutter now is silent and smooth. :) Regards.



回答2:

Also, in order to get current zoom value, use this code:

            Parameters parameters = mCamera.getParameters();
            List<Integer> zoom_list = parameters.getZoomRatios();

            int val = 0;

            if(isSamsungS4Zoom){
                    //FOR S4 ZOOM
                    mZoomVal = parameters.getInt("curr_zoom_level");
                    val = zoom_list.get(mZoomVal);
            }else{
                    val = zoom_list.get(mZoomVal);
            }