Java Code Examples for android.hardware.Camera#PreviewCallback
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: CameraManager.java From flutter_qr_reader with MIT License | 5 votes |
public void setPreviewCallback(Camera.PreviewCallback previewCallback) { this.previewCallback = previewCallback; if (isOpen()) { openCamera.getCamera().setPreviewCallback(previewCallback); } }
Example 2
Source File: CameraManager.java From DanDanPlayForAndroid with MIT License | 5 votes |
public void setPreviewCallback(Camera.PreviewCallback previewCallback) { this.previewCallback = previewCallback; if (isOpen()) { openCamera.getCamera().setPreviewCallback(previewCallback); } }
Example 3
Source File: CameraSession.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setPreviewCallback(Camera.PreviewCallback callback){ cameraInfo.camera.setPreviewCallback(callback); }
Example 4
Source File: VideoStream.java From spydroid-ipcamera with GNU General Public License v3.0 | 4 votes |
/** * Video encoding is done by a MediaCodec. */ @SuppressLint("NewApi") protected void encodeWithMediaCodecMethod1() throws RuntimeException, IOException { Log.d(TAG,"Video encoded using the MediaCodec API with a buffer"); // Updates the parameters of the camera if needed createCamera(); updateCamera(); // Estimates the framerate of the camera measureFramerate(); // Starts the preview if needed if (!mPreviewStarted) { try { mCamera.startPreview(); mPreviewStarted = true; } catch (RuntimeException e) { destroyCamera(); throw e; } } EncoderDebugger debugger = EncoderDebugger.debug(mSettings, mQuality.resX, mQuality.resY); final NV21Convertor convertor = debugger.getNV21Convertor(); mMediaCodec = MediaCodec.createByCodecName(debugger.getEncoderName()); MediaFormat mediaFormat = MediaFormat.createVideoFormat("video/avc", mQuality.resX, mQuality.resY); mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE, mQuality.bitrate); mediaFormat.setInteger(MediaFormat.KEY_FRAME_RATE, mQuality.framerate); mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT,debugger.getEncoderColorFormat()); mediaFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1); mMediaCodec.configure(mediaFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); mMediaCodec.start(); Camera.PreviewCallback callback = new Camera.PreviewCallback() { long now = System.nanoTime()/1000, oldnow = now, i=0; ByteBuffer[] inputBuffers = mMediaCodec.getInputBuffers(); @Override public void onPreviewFrame(byte[] data, Camera camera) { oldnow = now; now = System.nanoTime()/1000; if (i++>3) { i = 0; //Log.d(TAG,"Measured: "+1000000L/(now-oldnow)+" fps."); } try { int bufferIndex = mMediaCodec.dequeueInputBuffer(500000); if (bufferIndex>=0) { inputBuffers[bufferIndex].clear(); convertor.convert(data, inputBuffers[bufferIndex]); mMediaCodec.queueInputBuffer(bufferIndex, 0, inputBuffers[bufferIndex].position(), now, 0); } else { Log.e(TAG,"No buffer available !"); } } finally { mCamera.addCallbackBuffer(data); } } }; for (int i=0;i<10;i++) mCamera.addCallbackBuffer(new byte[convertor.getBufferSize()]); mCamera.setPreviewCallbackWithBuffer(callback); // The packetizer encapsulates the bit stream in an RTP stream and send it over the network mPacketizer.setDestination(mDestination, mRtpPort, mRtcpPort); mPacketizer.setInputStream(new MediaCodecInputStream(mMediaCodec)); mPacketizer.start(); mStreaming = true; }
Example 5
Source File: ICamera.java From MegviiFacepp-Android-SDK with Apache License 2.0 | 4 votes |
/** * 开始检测脸 */ public void actionDetect(Camera.PreviewCallback mActivity) { if (mCamera != null) { mCamera.setPreviewCallback(mActivity); } }
Example 6
Source File: DefaultEasyCamera.java From Expert-Android-Programming with MIT License | 4 votes |
@Override public void setOneShotPreviewCallback(Camera.PreviewCallback cb) { camera.setOneShotPreviewCallback(cb); }
Example 7
Source File: CameraPreview.java From smartcoins-wallet with MIT License | 4 votes |
public CameraPreview(Context context, AttributeSet attrs, Camera camera, Camera.PreviewCallback previewCallback) { super(context, attrs); init(camera, previewCallback); }
Example 8
Source File: CameraActivity.java From BluetoothCameraAndroid with MIT License | 4 votes |
@Override public void setCameraPreview(Camera.PreviewCallback previewCallback) { mCamera.setPreviewCallback(previewCallback); }
Example 9
Source File: Preview.java From cordova-plugin-camera-preview with MIT License | 4 votes |
public void setOneShotPreviewCallback(Camera.PreviewCallback callback) { if(mCamera != null) { mCamera.setOneShotPreviewCallback(callback); } }
Example 10
Source File: CameraPreview.java From alpha-wallet-android with MIT License | 4 votes |
public void setCamera(CameraWrapper cameraWrapper, Camera.PreviewCallback previewCallback) { mCameraWrapper = cameraWrapper; mPreviewCallback = previewCallback; }
Example 11
Source File: DefaultEasyCamera.java From Expert-Android-Programming with MIT License | 4 votes |
@Override public void setPreviewCallback(Camera.PreviewCallback cb) { camera.setPreviewCallback(cb); }
Example 12
Source File: CameraProxy.java From LiveVideoBroadcaster with Apache License 2.0 | 4 votes |
public void setPreviewCallbackWithBuffer(Camera.PreviewCallback callback) { _handler.obtainMessage(SET_PREVIEW_CALLBACK_WITH_BUFFER, callback).sendToTarget(); }
Example 13
Source File: DefaultEasyCamera.java From EasyCamera with Apache License 2.0 | 4 votes |
@Override public void setOneShotPreviewCallback(Camera.PreviewCallback cb) { camera.setOneShotPreviewCallback(cb); }
Example 14
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#setOneShotPreviewCallback%28android.hardware.Camera.PreviewCallback%29">Camera.setOneShotPreviewCallback(..)</a> */ void setOneShotPreviewCallback(Camera.PreviewCallback cb);
Example 15
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#setPreviewCallbackWithBuffer%28android.hardware.Camera.PreviewCallback%29">Camera.setPreviewCallbackWithBuffer(..)</a> */ void setPreviewCallbackWithBuffer(Camera.PreviewCallback cb);
Example 16
Source File: CameraManager.java From ZxingSupport with Apache License 2.0 | 2 votes |
/** * 响应预览图像 * * @param previewCallback */ public void requestPreview(Camera.PreviewCallback previewCallback) { if (mCamera != null) mCamera.setOneShotPreviewCallback(previewCallback); }
Example 17
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#setPreviewCallback%28android.hardware.Camera.PreviewCallback%29">Camera.setPreviewCallback(..)</a> */ void setPreviewCallback(Camera.PreviewCallback cb);
Example 18
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#setPreviewCallback%28android.hardware.Camera.PreviewCallback%29">Camera.setPreviewCallback(..)</a> */ void setPreviewCallback(Camera.PreviewCallback cb);
Example 19
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#setOneShotPreviewCallback%28android.hardware.Camera.PreviewCallback%29">Camera.setOneShotPreviewCallback(..)</a> */ void setOneShotPreviewCallback(Camera.PreviewCallback cb);
Example 20
Source File: CameraView.java From BluetoothCameraAndroid with MIT License | votes |
void setCameraPreview(Camera.PreviewCallback previewCallback);