三星s4变焦不支持平滑变焦isSmoothZoomSupported()== false

时间:2013-09-10 07:19:07

标签: android android-camera

我试图在我的相机记录应用程序中的“s4 zoom”设备上处理ZoomIn / ZoomOut。因为它只支持常规缩放,即parameters.isZoomSupported()==trueparameters.isSmoothZoomSupported()==false,所以我照常使用了parameters.setZoom(mZoomVal); mCamera.setParameters(parameters);。 问题是变焦是生涩,嘈杂而不平滑。 有没有人知道如何在“s4 zoom”中处理变焦速度,就像在三星相机应用程序中那样?

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;
        }
    });

}

2 个答案:

答案 0 :(得分:4)

我已经找到了三星S4 Zoom设备上快门控制快门镜头的解决方案。 将设备设置为智能模式parameters.set("mode", "smart-auto");

放大开始parameters.set("zoom-action", "optical-tele-start");

缩小开始parameters.set("zoom-action", "optical-wide-start");

缩放操作停止parameters.set("zoom-action", "zoom-stop");

快门速度parameters.set("zoom-speed", 1); //1,2,...

不要忘记在Camera实例mCamera.setParameters(parameters);

中保存参数

这在我的设备中工作正常,快门现在是安静和平稳的。 :) 问候。

答案 1 :(得分:2)

此外,为了获得当前缩放值,请使用以下代码:

            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);
            }