Java Code Examples for android.hardware.Camera#AutoFocusCallback
The following examples show how to use
android.hardware.Camera#AutoFocusCallback .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CameraActivity.java From cordova-plugin-camera-preview with MIT License | 6 votes |
public void setFocusArea(final int pointX, final int pointY, final Camera.AutoFocusCallback callback) { if (mCamera != null) { mCamera.cancelAutoFocus(); Camera.Parameters parameters = mCamera.getParameters(); Rect focusRect = calculateTapArea(pointX, pointY, 1f); parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); parameters.setFocusAreas(Arrays.asList(new Camera.Area(focusRect, 1000))); if (parameters.getMaxNumMeteringAreas() > 0) { Rect meteringRect = calculateTapArea(pointX, pointY, 1.5f); parameters.setMeteringAreas(Arrays.asList(new Camera.Area(meteringRect, 1000))); } try { setCameraParameters(parameters); mCamera.autoFocus(callback); } catch (Exception e) { Log.d(TAG, e.getMessage()); callback.onAutoFocus(false, this.mCamera); } } }
Example 2
Source File: Camera1.java From camerakit-android with MIT License | 5 votes |
void setTapToAutofocusListener(Camera.AutoFocusCallback callback) { if (this.mFocus != FOCUS_TAP) { throw new IllegalArgumentException("Please set the camera to FOCUS_TAP."); } this.mAutofocusCallback = callback; }
Example 3
Source File: CameraPreview.java From RecordVideo with Apache License 2.0 | 5 votes |
public boolean manualFocus(Camera camera, Camera.AutoFocusCallback cb, List<Camera.Area> focusAreas ,List<Camera.Area> mFocusAreas) { //判断系统是否是4.0以上的版本 if (camera != null && focusAreas != null && SystemVersionUtil.hasICS()) { try { camera.cancelAutoFocus(); Camera.Parameters parameters = camera.getParameters(); if(parameters != null){ // getMaxNumFocusAreas检测设备是否支持 if (parameters.getMaxNumFocusAreas() > 0) { parameters.setFocusAreas(focusAreas); } // getMaxNumMeteringAreas检测设备是否支持 if (parameters.getMaxNumMeteringAreas() > 0) parameters.setMeteringAreas(mFocusAreas); parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_MACRO); camera.setParameters(parameters); camera.autoFocus(cb); return true; } } catch (Exception e) { if (e != null) Log.e(" ", "autoFocus", e); } } return false; }
Example 4
Source File: CameraStreamerActivity.java From media-for-mobile with Apache License 2.0 | 5 votes |
private void startAutoFocus(Camera.AutoFocusCallback cb) { try { camera.autoFocus(cb); } catch (Exception e) { autoFocusSupported = false; String message = (e.getMessage() != null) ? e.getMessage() : e.toString(); showMessageBox(message, null); } }
Example 5
Source File: CameraCapturerActivity.java From media-for-mobile with Apache License 2.0 | 5 votes |
private void startAutoFocus(Camera.AutoFocusCallback cb) { try { camera.autoFocus(cb); } catch (Exception e) { autoFocusSupported = false; String message = (e.getMessage() != null) ? e.getMessage() : e.toString(); showMessageBox(message, null); } }
Example 6
Source File: DefaultEasyCamera.java From Expert-Android-Programming with MIT License | 4 votes |
@Override public void autoFocus(Camera.AutoFocusCallback cb) { camera.autoFocus(cb); }
Example 7
Source File: CameraProxy.java From LiveVideoBroadcaster with Apache License 2.0 | 4 votes |
public void autoFocus(Camera.AutoFocusCallback callback) { _handler.obtainMessage(AUTOFOCUS, callback).sendToTarget(); }
Example 8
Source File: CameraProxy.java From retroboy with MIT License | 4 votes |
public void autoFocus(Camera.AutoFocusCallback callback) { _handler.obtainMessage(AUTOFOCUS, callback).sendToTarget(); }
Example 9
Source File: DefaultEasyCamera.java From EasyCamera with Apache License 2.0 | 4 votes |
@Override public void autoFocus(Camera.AutoFocusCallback cb) { camera.autoFocus(cb); }
Example 10
Source File: EasyCamera.java From Expert-Android-Programming with MIT License | 2 votes |
/** * See <a href="http://developer.android.com/reference/android/hardware/Camera.html#autoFocus%28android.hardware.Camera.AutoFocusCallback%29">Camera.autoFocus(..)</a> */ void autoFocus(Camera.AutoFocusCallback cb);
Example 11
Source File: EasyCamera.java From EasyCamera with Apache License 2.0 | 2 votes |
/** * See <a href="http://developer.android.com/reference/android/hardware/Camera.html#autoFocus%28android.hardware.Camera.AutoFocusCallback%29">Camera.autoFocus(..)</a> */ void autoFocus(Camera.AutoFocusCallback cb);