Example usage for android.hardware Camera getCameraInfo

List of usage examples for android.hardware Camera getCameraInfo

Introduction

In this page you can find the example usage for android.hardware Camera getCameraInfo.

Prototype

public static void getCameraInfo(int cameraId, CameraInfo cameraInfo) 

Source Link

Document

Returns the information about a particular camera.

Usage

From source file:Main.java

public static boolean isCameraFacingBack(int cameraID) {
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraID, cameraInfo);
    return (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK);
}

From source file:Main.java

public static boolean isCameraFacing(int cameraID) {
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraID, cameraInfo);
    return (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT);
}

From source file:Main.java

public static int getFrontCameraId() {
    Camera.CameraInfo ci = new Camera.CameraInfo();
    for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
        Camera.getCameraInfo(i, ci);
        if (ci.facing == Camera.CameraInfo.CAMERA_FACING_FRONT)
            return i;
    }/*from  w w w .  j a  va 2 s . c  o m*/
    return -1; // No front-facing camera found
}

From source file:Main.java

public static int getDisplayOrientation(int cameraId) {
    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    int result;// w  w  w .  jav  a 2s  . co  m
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        result = (info.orientation) % 360;
        result = (360 - result) % 360; // compensate the mirror
    } else { // back-facing
        result = (info.orientation + 360) % 360;
    }
    return result;
}

From source file:Main.java

private static Camera getFrontCamera() {
    for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
        Camera.getCameraInfo(i, cameraInfo);

        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
            return Camera.open(i);
        }/*from  www . j  a va  2  s  .c o  m*/
    }

    return null;
}

From source file:Main.java

public static int getFrontCameraId() throws Exception {
    int numberOfCameras = Camera.getNumberOfCameras();
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    for (int i = 0; i < numberOfCameras; i++) {
        Camera.getCameraInfo(i, cameraInfo);
        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
            return i;
        }//from   w  ww. j ava2  s  . c  om
    }

    return 0;
}

From source file:Main.java

public static int getFrontCameraID() {
    int camerasCnt = getAvailableCamerasCount();
    int defaultCameraID = -1;
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    for (int i = 0; i < camerasCnt; i++) {
        Camera.getCameraInfo(i, cameraInfo);
        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
            defaultCameraID = i;/*from w  ww . j av  a  2s.  com*/
        }
    }
    return defaultCameraID;
}

From source file:Main.java

public static int getDefaultCameraID() {
    int camerasCnt = getAvailableCamerasCount();
    int defaultCameraID = -1;
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    for (int i = 0; i < camerasCnt; i++) {
        Camera.getCameraInfo(i, cameraInfo);
        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
            defaultCameraID = i;/*from  w  w w . j av a 2  s. co  m*/
        }
    }
    return defaultCameraID;
}

From source file:Main.java

public static int getFrontCameraId() {
    int cameraCount = 0;
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    cameraCount = Camera.getNumberOfCameras();
    for (int camIdx = 0; camIdx < cameraCount; camIdx++) {
        Camera.getCameraInfo(camIdx, cameraInfo);
        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
            return camIdx;
        }//  w  w w . j av  a 2 s  .co  m
    }
    return -1;
}

From source file:Main.java

public static int getCameraByDirection(int direction) {
    int numCameras = Camera.getNumberOfCameras();
    CameraInfo info = new CameraInfo();
    for (int camid = 0; camid < numCameras; camid++) {
        Camera.getCameraInfo(camid, info);
        if (info.facing == direction) {
            return camid;
        }//from  ww w .  jav  a 2  s  .c om
    }
    return -1;
}