Java Code Examples for android.hardware.Camera.CameraInfo#CAMERA_FACING_BACK
The following examples show how to use
android.hardware.Camera.CameraInfo#CAMERA_FACING_BACK .
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: CameraSurfaceView.java From Paddle-Lite-Demo with Apache License 2.0 | 6 votes |
public CameraSurfaceView(Context ctx, AttributeSet attrs) { super(ctx, attrs); context = ctx; setEGLContextClientVersion(2); setRenderer(this); setRenderMode(RENDERMODE_WHEN_DIRTY); // Find the total number of available cameras and the ID of the default camera numberOfCameras = Camera.getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { selectedCameraId = i; } } }
Example 2
Source File: CameraSurfaceView.java From Paddle-Lite-Demo with Apache License 2.0 | 6 votes |
public CameraSurfaceView(Context ctx, AttributeSet attrs) { super(ctx, attrs); context = ctx; setEGLContextClientVersion(2); setRenderer(this); setRenderMode(RENDERMODE_WHEN_DIRTY); // Find the total number of available cameras and the ID of the default camera numberOfCameras = Camera.getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { selectedCameraId = i; } } }
Example 3
Source File: CameraSurfaceView.java From Paddle-Lite-Demo with Apache License 2.0 | 6 votes |
public CameraSurfaceView(Context ctx, AttributeSet attrs) { super(ctx, attrs); context = ctx; setEGLContextClientVersion(2); setRenderer(this); setRenderMode(RENDERMODE_WHEN_DIRTY); // Find the total number of available cameras and the ID of the default camera numberOfCameras = Camera.getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { selectedCameraId = i; } } }
Example 4
Source File: CameraSurfaceView.java From Paddle-Lite-Demo with Apache License 2.0 | 6 votes |
public CameraSurfaceView(Context ctx, AttributeSet attrs) { super(ctx, attrs); context = ctx; setEGLContextClientVersion(2); setRenderer(this); setRenderMode(RENDERMODE_WHEN_DIRTY); // Find the total number of available cameras and the ID of the default camera numberOfCameras = Camera.getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { selectedCameraId = i; } } }
Example 5
Source File: CameraSurfaceView.java From Paddle-Lite-Demo with Apache License 2.0 | 6 votes |
public CameraSurfaceView(Context ctx, AttributeSet attrs) { super(ctx, attrs); context = ctx; setEGLContextClientVersion(2); setRenderer(this); setRenderMode(RENDERMODE_WHEN_DIRTY); // Find the total number of available cameras and the ID of the default camera numberOfCameras = Camera.getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { selectedCameraId = i; } } }
Example 6
Source File: CameraSurfaceView.java From Paddle-Lite-Demo with Apache License 2.0 | 6 votes |
public CameraSurfaceView(Context ctx, AttributeSet attrs) { super(ctx, attrs); context = ctx; setEGLContextClientVersion(2); setRenderer(this); setRenderMode(RENDERMODE_WHEN_DIRTY); // Find the total number of available cameras and the ID of the default camera numberOfCameras = Camera.getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { selectedCameraId = i; } } }
Example 7
Source File: SurfaceGrabberActivity.java From zom-android-matrix with Apache License 2.0 | 6 votes |
private boolean tryCreateCamera(int facing) { CameraInfo info = new CameraInfo(); for (int nCam = 0; nCam < Camera.getNumberOfCameras(); nCam++) { Camera.getCameraInfo(nCam, info); if (info.facing == facing) { camera = Camera.open(nCam); cameraInfo = info; //Size size = choosePictureSize(camera.getParameters().getSupportedPictureSizes()); Camera.Parameters params = camera.getParameters(); params.setPictureFormat(ImageFormat.JPEG); //params.setPictureSize(size.width,size.height); //params.setJpegThumbnailSize(128,128); //params.setPreviewSize(size.width/2,size.height/2); if (this.getCameraDirection() == CameraInfo.CAMERA_FACING_BACK) { params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); } camera.setParameters(params); return true; } } return false; }
Example 8
Source File: DisableCameraReceiver.java From Camera2 with Apache License 2.0 | 6 votes |
private boolean hasBackCamera() { int n = android.hardware.Camera.getNumberOfCameras(); CameraInfo info = new CameraInfo(); for (int i = 0; i < n; i++) { android.hardware.Camera.getCameraInfo(i, info); if (info.facing == CameraInfo.CAMERA_FACING_BACK) { Log.i(TAG, "back camera found: " + i); return true; } } Log.i(TAG, "no back camera"); return false; }
Example 9
Source File: PreMarshmallow.java From lantern with Apache License 2.0 | 5 votes |
private int getCameraId() { int numberOfCameras = Camera.getNumberOfCameras(); for (int i = 0; i < numberOfCameras; i++) { CameraInfo info = new CameraInfo(); Camera.getCameraInfo(i, info); if (info.facing == CameraInfo.CAMERA_FACING_BACK) { return i; } } return 0; }
Example 10
Source File: CameraApi2Activity.java From pixelvisualcorecamera with Apache License 2.0 | 5 votes |
/** Initializes cameraId state from global preferences. */ @SuppressWarnings("deprecation") private void initCameraSelection() { int cameraIdInt = preferences.getCameraId(); if (cameraIdInt > CameraInfo.CAMERA_FACING_FRONT) { Log.e(TAG, "out of bounds camera id: " + cameraIdInt); cameraIdInt = CameraInfo.CAMERA_FACING_BACK; preferences.setCameraId(cameraIdInt); } cameraId = String.valueOf(cameraIdInt); }
Example 11
Source File: CameraApi1Activity.java From pixelvisualcorecamera with Apache License 2.0 | 5 votes |
private void setCameraIconForCurrentCamera() { ImageButton button = findViewById(R.id.control_camera_selection); switch (cameraId) { case CameraInfo.CAMERA_FACING_BACK: button.setImageResource(R.drawable.ic_camera_rear_white_24); break; case CameraInfo.CAMERA_FACING_FRONT: button.setImageResource(R.drawable.ic_camera_front_white_24); break; default: break; } }
Example 12
Source File: CameraApi1Activity.java From pixelvisualcorecamera with Apache License 2.0 | 5 votes |
/** Initializes cameraId state from global preferences. */ private void initCameraSelection() { cameraId = preferences.getCameraId(); if (cameraId > CameraInfo.CAMERA_FACING_FRONT) { Log.e(TAG, "out of bounds camera id: " + cameraId); cameraId = CameraInfo.CAMERA_FACING_BACK; preferences.setCameraId(cameraId); } }
Example 13
Source File: LegacyCameraConnectionFragment.java From dbclf with Apache License 2.0 | 5 votes |
private int getCameraId() { CameraInfo ci = new CameraInfo(); for (int i = 0; i < Camera.getNumberOfCameras(); i++) { Camera.getCameraInfo(i, ci); if (ci.facing == CameraInfo.CAMERA_FACING_BACK) return i; } return -1; // No camera found }
Example 14
Source File: LegacyCameraConnectionFragment.java From next18-ai-in-motion with Apache License 2.0 | 5 votes |
private int getCameraId() { CameraInfo ci = new CameraInfo(); for (int i = 0; i < Camera.getNumberOfCameras(); i++) { Camera.getCameraInfo(i, ci); if (ci.facing == CameraInfo.CAMERA_FACING_BACK) return i; } return -1; // No camera found }
Example 15
Source File: CameraView.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
public void flipCamera() { if (Camera.getNumberOfCameras() > 1) { cameraId = cameraId == CameraInfo.CAMERA_FACING_BACK ? CameraInfo.CAMERA_FACING_FRONT : CameraInfo.CAMERA_FACING_BACK; onPause(); onResume(); TextSecurePreferences.setDirectCaptureCameraId(getContext(), cameraId); } }
Example 16
Source File: SecureCameraActivity.java From zom-android-matrix with Apache License 2.0 | 4 votes |
@Override protected int getCameraDirection() { //return CameraInfo.CAMERA_FACING_FRONT; return CameraInfo.CAMERA_FACING_BACK; }
Example 17
Source File: SurfaceGrabberActivity.java From zom-android-matrix with Apache License 2.0 | 4 votes |
private int getOtherDirection(int facing) { return (facing == CameraInfo.CAMERA_FACING_BACK) ? CameraInfo.CAMERA_FACING_FRONT : CameraInfo.CAMERA_FACING_BACK; }
Example 18
Source File: SurfaceGrabberActivity.java From zom-android-matrix with Apache License 2.0 | 4 votes |
protected int getCameraDirection() { return CameraInfo.CAMERA_FACING_BACK; }
Example 19
Source File: CodeScanner.java From code-scanner with MIT License | 4 votes |
private void initialize() { Camera camera = null; final CameraInfo cameraInfo = new CameraInfo(); final int cameraId = mCameraId; if (cameraId == CAMERA_BACK || cameraId == CAMERA_FRONT) { final int numberOfCameras = Camera.getNumberOfCameras(); final int facing = cameraId == CAMERA_BACK ? CameraInfo.CAMERA_FACING_BACK : CameraInfo.CAMERA_FACING_FRONT; for (int i = 0; i < numberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == facing) { camera = Camera.open(i); mCameraId = i; break; } } } else { camera = Camera.open(cameraId); Camera.getCameraInfo(cameraId, cameraInfo); } if (camera == null) { throw new CodeScannerException("Unable to access camera"); } final Parameters parameters = camera.getParameters(); if (parameters == null) { throw new CodeScannerException("Unable to configure camera"); } final int orientation = Utils.getDisplayOrientation(mContext, cameraInfo); final boolean portrait = Utils.isPortrait(orientation); final Point imageSize = Utils.findSuitableImageSize(parameters, portrait ? mHeight : mWidth, portrait ? mWidth : mHeight); final int imageWidth = imageSize.getX(); final int imageHeight = imageSize.getY(); parameters.setPreviewSize(imageWidth, imageHeight); parameters.setPreviewFormat(ImageFormat.NV21); final Point previewSize = Utils.getPreviewSize(portrait ? imageHeight : imageWidth, portrait ? imageWidth : imageHeight, mWidth, mHeight); final List<String> focusModes = parameters.getSupportedFocusModes(); final boolean autoFocusSupported = focusModes != null && (focusModes.contains(Parameters.FOCUS_MODE_AUTO) || focusModes.contains(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)); if (!autoFocusSupported) { mAutoFocusEnabled = false; } final Point viewSize = new Point(mWidth, mHeight); if (autoFocusSupported && mAutoFocusEnabled) { Utils.setAutoFocusMode(parameters, mAutoFocusMode); final Rect frameRect = mScannerView.getFrameRect(); if (frameRect != null) { Utils.configureDefaultFocusArea(parameters, frameRect, previewSize, viewSize, imageWidth, imageHeight, orientation); } } final List<String> flashModes = parameters.getSupportedFlashModes(); final boolean flashSupported = flashModes != null && flashModes.contains(Parameters.FLASH_MODE_TORCH); if (!flashSupported) { mFlashEnabled = false; } final int zoom = mZoom; if (zoom != 0) { Utils.setZoom(parameters, zoom); } Utils.configureFpsRange(parameters); Utils.configureSceneMode(parameters); Utils.configureVideoStabilization(parameters); camera.setParameters(parameters); camera.setDisplayOrientation(orientation); synchronized (mInitializeLock) { final Decoder decoder = new Decoder(mDecoderStateListener, mFormats, mDecodeCallback); mDecoderWrapper = new DecoderWrapper(camera, cameraInfo, decoder, imageSize, previewSize, viewSize, orientation, autoFocusSupported, flashSupported); decoder.start(); mInitialization = false; mInitialized = true; } mMainThreadHandler.post(new FinishInitializationTask(previewSize)); }
Example 20
Source File: CameraView.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
public boolean isRearCamera() { return cameraId == CameraInfo.CAMERA_FACING_BACK; }