List of usage examples for android.hardware Camera getNumberOfCameras
public native static int getNumberOfCameras();
From source file:Main.java
public static Camera.CameraInfo[] getCameraArray(Context context) { Camera.CameraInfo[] cameraArray = null; if (isCameraPresent(context)) { int numCameras = Camera.getNumberOfCameras(); if (numCameras > 0) { cameraArray = new Camera.CameraInfo[numCameras]; for (int ii = 0; ii < numCameras; ++ii) { cameraArray[ii] = new Camera.CameraInfo(); Camera.getCameraInfo(ii, cameraArray[ii]); }/*w ww . j ava 2 s. c om*/ } } return cameraArray; }
From source file:Main.java
private static Camera.CameraInfo getCameraInfo() { Camera.CameraInfo info = new Camera.CameraInfo(); for (int i = 0; i < Camera.getNumberOfCameras(); i++) { Camera.getCameraInfo(i, info);// w w w . j av a 2 s .c o m if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) { break; } } return info; }
From source file:Main.java
/** * @return a mapping of all camera ids to matching camera info *//* ww w . j a v a 2s .co m*/ public static Map<Integer, Camera.CameraInfo> getCameras() { Map<Integer, Camera.CameraInfo> cameraMap = new HashMap<Integer, Camera.CameraInfo>(); int numberOfCameras = Camera.getNumberOfCameras(); Camera.CameraInfo cameraInfo = null; for (int i = 0; i < numberOfCameras; i++) { cameraInfo = new Camera.CameraInfo(); Camera.getCameraInfo(i, cameraInfo); cameraMap.put(i, cameraInfo); } return cameraMap; }
From source file:Main.java
/** * Checks whether this device support a front camera. * @return true if this device support a front camera, false otherwise *///w ww . j av a2 s .co m public static boolean hasFrontFacingDevice() { for (int i = 0; i < Camera.getNumberOfCameras(); ++i) { Camera.CameraInfo info = new Camera.CameraInfo(); try { Camera.getCameraInfo(i, info); if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { return true; } } catch (Exception e) { // do nothing. } } return false; }
From source file:Main.java
/** * Get camera id of specified camera face * @param cameraFace must be one of {@link CameraInfo#CAMERA_FACING_FRONT} * and {@link CameraInfo#CAMERA_FACING_BACK} * @return the camera id// w w w . java2 s.c om */ public static int getCameraId(int cameraFace) { int cameraId = 0; int numberOfCameras = Camera.getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == cameraFace) { cameraId = i; break; } } return cameraId; }
From source file:Main.java
/** * Return camera instance/*from w w w . j a v a2 s. com*/ */ public static Camera getCameraInstance(int displayOrientation) { Camera cam = null; try { cam = Camera.open(); // More efficient way to find available cameras. Nexus 7 needs this. if (cam == null) { int availableCameras = Camera.getNumberOfCameras(); for (int i = 0; i < availableCameras; i++) { cam = Camera.open(i); if (cam != null) break; } } cam.setDisplayOrientation(displayOrientation); Log.d(TAG, "Getting Camera: " + cam.toString()); } catch (Exception e) { Log.e(TAG, "Camera is not available (in use or does not exist)"); Log.e(TAG, e.toString()); } return cam; }
From source file:Main.java
public static int getAvailableCamerasCount() { return Camera.getNumberOfCameras(); }
From source file:Main.java
public static int getCameraNumber() { if (cameraNumber == -1) { cameraNumber = Camera.getNumberOfCameras(); }// w ww . ja va 2 s.c om return cameraNumber; }
From source file:Main.java
public static boolean areBothCamerasSupported() { return (Camera.getNumberOfCameras() > 1); }
From source file:Main.java
public static boolean isCameraSupported(int cameraId) { return (Camera.getNumberOfCameras() > cameraId); }