Java Code Examples for android.hardware.Camera#startPreview()
The following examples show how to use
android.hardware.Camera#startPreview() .
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: CameraEngine.java From Fatigue-Detection with MIT License | 7 votes |
public void takePhoto(){ Camera.ShutterCallback shutterCallback = new Camera.ShutterCallback() { public void onShutter() { Log.d(TAG, "onShutter: "); } }; Camera.PictureCallback jpegCallback = new Camera.PictureCallback() { public void onPictureTaken(final byte[] data, final Camera camera) { camera.startPreview(); Log.d(TAG, "onPictureTaken: "); pictureTakenCallBack.saveAsBitmap(data); } }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { camera.enableShutterSound(false); } camera.takePicture(shutterCallback, null, jpegCallback); }
Example 2
Source File: CameraManager.java From Android with MIT License | 6 votes |
/** * Set the camera to camera (turn off the old camera, turn on the new camera) * * @param mCamera */ public Camera setChangeParameters(Activity activity, Camera mCamera, SurfaceHolder viewHolder) { if (Camera.getNumberOfCameras() <= 1) { return null; } try { mCamera.stopPreview(); mCamera.setPreviewCallback(null); mCamera.release(); cameraPosition = cameraPosition == 1 ? 0 : 1; Camera mNewCamera = getCameraInstance(cameraPosition); setParametersCamera(activity, mNewCamera); mNewCamera.setPreviewDisplay(viewHolder); mNewCamera.startPreview(); return mNewCamera; } catch (Exception e) { e.printStackTrace(); } return null; }
Example 3
Source File: CameraManager.java From Android with MIT License | 6 votes |
/** * Initialize the camera */ public Camera initCamera(Activity activity, SurfaceHolder viewHolder) { this.viewHolder = viewHolder; Camera mCamera = getCameraInstance(0); try { setParametersCamera(activity, mCamera); // Determine whether to support flash List<String> features = mCamera.getParameters().getSupportedFlashModes(); if (null == features || features.contains(Camera.Parameters.FLASH_MODE_ON)) { isLighting = false; isSupportedLight = true; } mCamera.setPreviewDisplay(viewHolder); mCamera.startPreview(); } catch (Exception e) { e.printStackTrace(); } return mCamera; }
Example 4
Source File: GPUImageRenderer.java From Fatigue-Detection with MIT License | 6 votes |
private void setUpSurfaceTextureInternal(final Camera camera, byte[] data) { if (null == camera) { log.error("setup camera failed, camera is null"); return; } int[] textures = new int[1]; GLES20.glGenTextures(1, textures, 0); mSurfaceTexture = new SurfaceTexture(textures[0]); try { camera.addCallbackBuffer(data); camera.setPreviewTexture(mSurfaceTexture); camera.setPreviewCallbackWithBuffer(GPUImageRenderer.this); camera.startPreview(); } catch (Exception e) { log.error("setup camera failed, " + e.getMessage()); } log.debug("setUpSurfaceTextureInternal " + camera + " " + data.length); }
Example 5
Source File: CameraContainer.java From LLApp with Apache License 2.0 | 5 votes |
@Override public void onPictureTaken(byte[] data, Camera camera) { if(mSavePath==null) throw new RuntimeException("mSavePath is null"); if(mDataHandler==null) mDataHandler=new DataHandler(); mDataHandler.setMaxSize(200); Bitmap bm=mDataHandler.save(data); mTempImageView.setListener(mListener); mTempImageView.isVideo(false); mTempImageView.setImageBitmap(bm); mTempImageView.startAnimation(R.anim.tempview_show); //重新打开预览图,进行下一次的拍照准备 camera.startPreview(); if(mListener!=null) mListener.onTakePictureEnd(bm); }
Example 6
Source File: CameraManager.java From Android with MIT License | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public synchronized void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { theCamera.startPreview(); previewing = true; autoFocusManager = new AutoFocusManager(context, camera); } }
Example 7
Source File: JCameraView.java From CameraView with Apache License 2.0 | 5 votes |
private void setStartPreview(Camera camera, SurfaceHolder holder) { try { Camera.Parameters parameters = mCamera.getParameters(); parameters.setPictureFormat(ImageFormat.JPEG); List<Camera.Size> sizeList = parameters.getSupportedPreviewSizes();//获取所有支持的camera尺寸 Iterator<Camera.Size> itor = sizeList.iterator(); while (itor.hasNext()) { Camera.Size cur = itor.next(); Log.i("CJT", "所有的 width = " + cur.width + " height = " + cur.height); if (cur.width >= width&& cur.height >= height) { width = cur.width; height = cur.height; } } Log.i("size", "width : height" + width + " : " + height + " ==== " + getWidth() + " : " + getHeight()); parameters.setPreviewSize(width, height);//把camera.size赋值到parameters parameters.setPictureSize(width, height); parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); camera.setParameters(parameters); camera.setPreviewDisplay(holder); camera.setDisplayOrientation(90); camera.startPreview(); } catch (IOException e) { e.printStackTrace(); } }
Example 8
Source File: CameraManager.java From zxingfragmentlib with Apache License 2.0 | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public synchronized void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { theCamera.startPreview(); previewing = true; autoFocusManager = new AutoFocusManager(context, camera); } }
Example 9
Source File: CameraManager.java From myapplication with Apache License 2.0 | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public synchronized void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { theCamera.startPreview(); previewing = true; autoFocusManager = new AutoFocusManager(context, camera); } }
Example 10
Source File: CameraManager.java From android-apps with MIT License | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { theCamera.startPreview(); previewing = true; } }
Example 11
Source File: CameraManager.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public synchronized void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { theCamera.startPreview(); previewing = true; autoFocusManager = new AutoFocusManager(context, camera); } }
Example 12
Source File: CameraManager.java From ZXingProject with MIT License | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public synchronized void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { theCamera.startPreview(); previewing = true; autoFocusManager = new AutoFocusManager(context, camera); } }
Example 13
Source File: CameraManager.java From FoodOrdering with Apache License 2.0 | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public synchronized void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { theCamera.startPreview(); previewing = true; autoFocusManager = new AutoFocusManager(context, camera); } }
Example 14
Source File: CameraManager.java From ScanZbar with Apache License 2.0 | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public synchronized void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { // Starts capturing and drawing preview frames to the screen // Preview will not actually start until a surface is supplied with // setPreviewDisplay(SurfaceHolder) or // setPreviewTexture(SurfaceTexture). theCamera.startPreview(); previewing = true; autoFocusManager = new AutoFocusManager(context, camera); } }
Example 15
Source File: CameraManager.java From GOpenSource_AppKit_Android_AS with MIT License | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public synchronized void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { theCamera.startPreview(); previewing = true; autoFocusManager = new AutoFocusManager(context, camera); } }
Example 16
Source File: CameraManager.java From ZbarCode with Apache License 2.0 | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public synchronized void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { // Starts capturing and drawing preview frames to the screen // Preview will not actually start until a surface is supplied with // setPreviewDisplay(SurfaceHolder) or // setPreviewTexture(SurfaceTexture). theCamera.startPreview(); previewing = true; autoFocusManager = new AutoFocusManager(context, camera); } }
Example 17
Source File: CameraManager.java From ZXing-Orient with Apache License 2.0 | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public synchronized void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { theCamera.startPreview(); previewing = true; autoFocusManager = new AutoFocusManager(context, camera,autoFocusRequest); } }
Example 18
Source File: CameraManager.java From BarcodeEye with Apache License 2.0 | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public synchronized void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { theCamera.startPreview(); previewing = true; autoFocusManager = new AutoFocusManager(context, camera); } }
Example 19
Source File: CameraPreview.java From cordova-plugin-camera-preview with MIT License | 5 votes |
private boolean setPreviewSize(int width, int height, CallbackContext callbackContext) { if(this.hasCamera(callbackContext) == false){ return true; } Camera camera = fragment.getCamera(); Camera.Parameters params = camera.getParameters(); params.setPreviewSize(width, height); fragment.setCameraParameters(params); camera.startPreview(); callbackContext.success(); return true; }
Example 20
Source File: CameraManager.java From FamilyChat with Apache License 2.0 | 5 votes |
/** * Asks the camera hardware to begin drawing preview frames to the screen. */ public synchronized void startPreview() { Camera theCamera = camera; if (theCamera != null && !previewing) { theCamera.startPreview(); previewing = true; autoFocusManager = new AutoFocusManager(context, camera); } }