4

我正在尝试制作一个自定义相机应用程序,我想让用户可以在此应用程序中选择对焦模式。

对焦模式默认为自动对焦。

如果我想将cameraView设置为可点击,这样当我在屏幕上触摸一个点时,相机的焦点就在那个点上?怎么可能开始?以下是我的代码

public void takePhoto(File photoFile, String workerName, int width, int height,   int        quality) {
if (getAutoFocusStatus()){
    camera.autoFocus(new AutoFocusCallback() {
        @Override
        public void onAutoFocus(boolean success, Camera camera) {
            camera.takePicture(shutterCallback, rawCallback, jpegCallback);
        }
    }); 
}else{
    camera.takePicture(shutterCallback, rawCallback, jpegCallback);
}

this.photoFile = photoFile;
this.workerName = workerName;
this.imageOutputWidth = width;
this.imageOutputHeight = height;
}

public void takePhoto(File photoFile, int width, int height, int quality) {
takePhoto(photoFile, null, width, height, quality);
}
4

1 回答 1

4

当你触摸屏幕上的一个点时,你应该得到一个Camera.Area。只有当前对焦模式为 FOCUS_MODE_AUTO、FOCUS_MODE_MACRO、FOCUS_MODE_CONTINUOUS_VIDEO 或 FOCUS_MODE_CONTINUOUS_PICTURE 时,对焦区域才有效。然后你应该调用方法setFocusAreas来触发焦点。相机的视野从左上角 (-1000, -1000) 映射到右下角 (1000, 1000)。所以你必须进行坐标转换。

于 2013-08-22T02:14:20.100 回答