/** * A single preview frame will be returned to the supplied callback. * * The thread on which this called is undefined, so a Handler should be used to post the result * to the correct thread. * * @param callback The callback to receive the preview. */ public void requestPreviewFrame(PreviewCallback callback) { Camera theCamera = camera; if (theCamera != null && previewing) { cameraPreviewCallback.setCallback(callback); theCamera.setOneShotPreviewCallback(cameraPreviewCallback); } }
/** * A single preview frame will be returned to the handler supplied. The data will arrive as byte[] * in the message.obj field, with width and height encoded as message.arg1 and message.arg2, * respectively. * * @param handler The handler to send the message to. * @param message The what field of the message to be sent. */ public synchronized void requestPreviewFrame(Handler handler, int message) { Camera theCamera = camera; if (theCamera != null && previewing) { previewCallback.setHandler(handler, message); theCamera.setOneShotPreviewCallback(previewCallback); } }
/** * A single preview frame will be returned to the handler supplied. The data will arrive as byte[] * in the message.obj field, with width and height encoded as message.arg1 and message.arg2, * respectively. * * @param handler The handler to send the message to. * @param message The what field of the message to be sent. */ public synchronized void requestOcrDecode(Handler handler, int message) { Camera theCamera = camera; if (theCamera != null && previewing) { previewCallback.setHandler(handler, message); theCamera.setOneShotPreviewCallback(previewCallback); } }
public void stopCameraPreview() { if(mCameraWrapper != null) { try { mPreviewing = false; getHolder().removeCallback(this); mCameraWrapper.mCamera.cancelAutoFocus(); mCameraWrapper.mCamera.setOneShotPreviewCallback(null); mCameraWrapper.mCamera.stopPreview(); } catch(Exception e) { Log.e(TAG, e.toString(), e); } } }
/** * A single preview frame will be returned to the handler supplied. The data will arrive as byte[] * in the message.obj field, with width and height encoded as message.arg1 and message.arg2, * respectively. * * @param handler The handler to send the message to. * @param message The what field of the message to be sent. */ public void requestPreviewFrame(Handler handler, int message) { if (camera != null && previewing) { previewCallback.setHandler(handler, message); if (useOneShotPreviewCallback) { camera.setOneShotPreviewCallback(previewCallback); } else { camera.setPreviewCallback(previewCallback); } } }
/** * A single preview frame will be returned to the handler supplied. The data will arrive as byte[] * in the message.obj field, with width and height encoded as message.arg1 and message.arg2, * respectively. * * @param handler The handler to send the message to. * @param message The what field of the message to be sent. */ public void requestPreviewFrame(Handler handler, int message) { if (camera != null && previewing) { previewCallback.setHandler(handler, message); if (useOneShotPreviewCallback) { camera.setOneShotPreviewCallback(previewCallback); } else { camera.setPreviewCallback(previewCallback); } } }
/** * A single preview frame will be returned to the handler supplied. The data will arrive as byte[] * in the message.obj field, with width and height encoded as message.arg1 and message.arg2, * respectively. * * @param handler The handler to send the message to. * @param message The what field of the message to be sent. */ public void requestPreviewFrame(Handler handler, int message) { if (camera != null && previewing) { previewCallback.setHandler(handler, message); if (useOneShotPreviewCallback) { camera.setOneShotPreviewCallback(previewCallback); } else { camera.setPreviewCallback(previewCallback); } } }
public void showCameraPreview() { if(mCameraWrapper != null) { try { getHolder().addCallback(this); mPreviewing = true; setupCameraParameters(); mCameraWrapper.mCamera.setPreviewDisplay(getHolder()); mCameraWrapper.mCamera.setDisplayOrientation(getDisplayOrientation()); mCameraWrapper.mCamera.setOneShotPreviewCallback(mPreviewCallback); mCameraWrapper.mCamera.startPreview(); if(mAutoFocus) { if (mSurfaceCreated) { // check if surface created before using autofocus safeAutoFocus(); } else { scheduleAutoFocus(); // wait 1 sec and then do check again } } } catch (Exception e) { Log.e(TAG, e.toString(), e); } } }
@Test public void testSetOneShotPreviewCallbacks() throws Exception { TestPreviewCallback callback = new TestPreviewCallback(); assertThat(callback.camera).isNull(); assertThat(callback.data).isNull(); camera.setOneShotPreviewCallback(callback); shadowCamera.invokePreviewCallback("foobar".getBytes(UTF_8)); assertThat(callback.camera).isSameAs(camera); assertThat(callback.data).isEqualTo("foobar".getBytes(UTF_8)); }
@Test public void testClearPreviewCallback() throws Exception { TestPreviewCallback callback = new TestPreviewCallback(); assertThat(callback.camera).isNull(); assertThat(callback.data).isNull(); camera.setPreviewCallback(callback); camera.setPreviewCallback(null); shadowCamera.invokePreviewCallback("foobar".getBytes(UTF_8)); assertThat(callback.camera).isNull(); assertThat(callback.data).isNull(); camera.setOneShotPreviewCallback(callback); camera.setOneShotPreviewCallback(null); shadowCamera.invokePreviewCallback("foobar".getBytes(UTF_8)); assertThat(callback.camera).isNull(); assertThat(callback.data).isNull(); camera.setPreviewCallbackWithBuffer(callback); camera.setPreviewCallbackWithBuffer(null); shadowCamera.invokePreviewCallback("foobar".getBytes(UTF_8)); assertThat(callback.camera).isNull(); assertThat(callback.data).isNull(); }
public void requestPreviewFrame(final PreviewCallback callback) { camera.setOneShotPreviewCallback(callback); }
public void requestPreviewFrame(final PreviewCallback callback) { camera.setOneShotPreviewCallback(callback); }
@Override public void run() { if (mCamera != null && mSpotAble) { try { mCamera.setOneShotPreviewCallback(QRCodeView.this); } catch (Exception e) { e.printStackTrace(); } } } };
@Override public void run() { if (mCamera != null && mSpotAble) { try { mCamera.setOneShotPreviewCallback(QRCodeView.this); } catch (Exception e) { e.printStackTrace(); } } } };
@Override public void run() { if (mCamera != null && mSpotAble) { try { mCamera.setOneShotPreviewCallback(QRCodeView.this); } catch (Exception e) { e.printStackTrace(); } } } };
/** * A single preview frame will be returned to the handler supplied. The data will arrive as byte[] in the * message.obj field, with width and height encoded as message.arg1 and message.arg2, respectively. * * @param handler The handler to send the message to. * @param message The what field of the message to be sent. */ public void requestPreviewFrame(Handler handler, int message) { if (mCamera != null && mPreviewing) { mPreviewCallback.setHandler(handler, message); mCamera.setOneShotPreviewCallback(mPreviewCallback); } }
/** * A single preview frame will be returned to the handler supplied. The data will arrive as byte[] in the * message.obj field, with width and height encoded as message.arg1 and message.arg2, respectively. * * @param handler The handler to send the message to. * @param message The what field of the message to be sent. */ public void requestPreviewFrame(Handler handler, int message) { if (mCamera != null && mPreviewing) { mPreviewCallback.setHandler(handler, message); mCamera.setOneShotPreviewCallback(mPreviewCallback); } }
synchronized public void setOneShotPreviewCallback(Camera.PreviewCallback callback) { checkTaken(); camera.setOneShotPreviewCallback(callback); }
public void stopCameraPreview() { if (mCamera != null) { try { removeCallbacks(doAutoFocus); mPreviewing = false; mCamera.cancelAutoFocus(); mCamera.setOneShotPreviewCallback(null); mCamera.stopPreview(); } catch (Exception e) { Log.e(TAG, e.toString(), e); } } }
public void stopCameraPreview() { if (mCamera != null) { try { removeCallbacks(doAutoFocus); mPreviewing = false; mCamera.cancelAutoFocus(); mCamera.setOneShotPreviewCallback(null); mCamera.stopPreview(); } catch (Exception e) { Log.e(TAG, e.toString(), e); } } }