android.hardware.Camera.PreviewCallback Java Examples
The following examples show how to use
android.hardware.Camera.PreviewCallback.
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: FaceOverlapFragment.java From Fatigue-Detection with MIT License | 6 votes |
@SuppressLint("NewApi") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); nv21 = new byte[PREVIEW_WIDTH * PREVIEW_HEIGHT * 2]; this.setPreviewCallback(new PreviewCallback() { @Override public void onPreviewFrame(byte[] data, Camera camera) { synchronized (nv21) { System.arraycopy(data, 0, nv21, 0, data.length); isNV21ready = true; } } }); return view; }
Example #2
Source File: CameraManager.java From bcm-android with GNU General Public License v3.0 | 5 votes |
public void requestPreviewFrame(final PreviewCallback callback) { try { camera.setOneShotPreviewCallback(callback); } catch (final RuntimeException x) { Logger.e(x, "problem requesting preview frame, callback won't be called"); } }
Example #3
Source File: CameraPreview.java From imsdk-android with MIT License | 5 votes |
@SuppressWarnings("deprecation") public CameraPreview(Context context, Camera camera, PreviewCallback previewCb, AutoFocusCallback autoFocusCb) { super(context); mCamera = camera; previewCallback = previewCb; autoFocusCallback = autoFocusCb; /* * Set camera to continuous focus if supported, otherwise use software * auto-focus. Only works for API level >=9. */ /* * Camera.Parameters parameters = camera.getParameters(); for (String f * : parameters.getSupportedFocusModes()) { if (f == * Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) { * mCamera.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); * autoFocusCallback = null; break; } } */ // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. mHolder = getHolder(); mHolder.addCallback(this); // deprecated setting, but required on Android versions prior to 3.0 mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }
Example #4
Source File: CameraPreview.java From ScanZbar with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") public CameraPreview(Context context, Camera camera, PreviewCallback previewCb, AutoFocusCallback autoFocusCb) { super(context); mCamera = camera; previewCallback = previewCb; autoFocusCallback = autoFocusCb; /* * Set camera to continuous focus if supported, otherwise use software * auto-focus. Only works for API level >=9. */ Camera.Parameters parameters = camera.getParameters(); for (String f: parameters.getSupportedFocusModes()) { if (f == Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) { parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); autoFocusCallback = null; break; } } // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. mHolder = getHolder(); mHolder.addCallback(this); // deprecated setting, but required on Android versions prior to 3.0 mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }
Example #5
Source File: CameraManager.java From green_android with GNU General Public License v3.0 | 5 votes |
public void requestPreviewFrame(final PreviewCallback callback) { try { camera.setOneShotPreviewCallback(callback); } catch (final RuntimeException x) { log.warn("problem requesting preview frame, callback won't be called", x); } }
Example #6
Source File: CameraProxy.java From CameraDemo with Apache License 2.0 | 5 votes |
public void setPreviewCallback(PreviewCallback previewCallback) { mPreviewCallback = previewCallback; if (mPreviewBuffer == null) { mPreviewBuffer = new byte[mPreviewWidth * mPreviewHeight * 3 / 2]; } mCamera.addCallbackBuffer(mPreviewBuffer); mCamera.setPreviewCallbackWithBuffer(mPreviewCallback); // 设置预览的回调 }
Example #7
Source File: CameraPreview.java From ZbarCode with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") public CameraPreview(Context context, Camera camera, PreviewCallback previewCb, AutoFocusCallback autoFocusCb) { super(context); mCamera = camera; previewCallback = previewCb; autoFocusCallback = autoFocusCb; /* * Set camera to continuous focus if supported, otherwise use software * auto-focus. Only works for API level >=9. */ Camera.Parameters parameters = camera.getParameters(); for (String f: parameters.getSupportedFocusModes()) { if (f == Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) { parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); autoFocusCallback = null; break; } } // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. mHolder = getHolder(); mHolder.addCallback(this); // deprecated setting, but required on Android versions prior to 3.0 mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }
Example #8
Source File: ScanActivity.java From GreenBits with GNU General Public License v3.0 | 5 votes |
@Override public void run() { cameraManager.requestPreviewFrame(new PreviewCallback() { @Override public void onPreviewFrame(final byte[] data, final Camera camera) { decode(data); } }); }
Example #9
Source File: ScanActivity.java From bither-android with Apache License 2.0 | 5 votes |
@Override public void run() { if (fromGallery) { cameraHandler.postDelayed(fetchAndDecodeRunnable, 500); return; } cameraManager.requestPreviewFrame(new PreviewCallback() { @Override public void onPreviewFrame(final byte[] data, final Camera camera) { decode(data); } }); }
Example #10
Source File: CameraPreview.java From ZBarScanProj with MIT License | 5 votes |
@SuppressWarnings("deprecation") public CameraPreview(Context context, Camera camera, PreviewCallback previewCb, AutoFocusCallback autoFocusCb) { super(context); mCamera = camera; previewCallback = previewCb; autoFocusCallback = autoFocusCb; /* * Set camera to continuous focus if supported, otherwise use software * auto-focus. Only works for API level >=9. */ /* * Camera.Parameters parameters = camera.getParameters(); for (String f * : parameters.getSupportedFocusModes()) { if (f == * Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) { * mCamera.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); * autoFocusCallback = null; break; } } */ // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. mHolder = getHolder(); mHolder.addCallback(this); // deprecated setting, but required on Android versions prior to 3.0 mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }
Example #11
Source File: CameraManager.java From Conversations with GNU General Public License v3.0 | 5 votes |
public void requestPreviewFrame(final PreviewCallback callback) { try { camera.setOneShotPreviewCallback(callback); } catch (final RuntimeException x) { Log.d(Config.LOGTAG,"problem requesting preview frame, callback won't be called", x); } }
Example #12
Source File: CameraPreview.java From faceswap with Apache License 2.0 | 4 votes |
public void setPreviewCallback(PreviewCallback previewCallback) { if (this.mCamera != null){ mCamera.setPreviewCallback(previewCallback); } }
Example #13
Source File: CameraManager.java From GreenBits with GNU General Public License v3.0 | 4 votes |
public void requestPreviewFrame(final PreviewCallback callback) { camera.setOneShotPreviewCallback(callback); }
Example #14
Source File: CameraManager.java From bither-android with Apache License 2.0 | 4 votes |
public void requestPreviewFrame(final PreviewCallback callback) { camera.setOneShotPreviewCallback(callback); }
Example #15
Source File: CameraPreview.java From meatspace-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public PreviewCallback getPreviewCallback() { return previewCallback; }
Example #16
Source File: CameraPreview.java From meatspace-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void setPreviewCallback(PreviewCallback previewCallback) { this.previewCallback = previewCallback; if (camera != null) { camera.setPreviewCallback(previewCallback); } }