use of android.hardware.Camera.CameraInfo in project libstreaming by fyhertz.
the class VideoStream method setCamera.
/**
* Sets the camera that will be used to capture video.
* You can call this method at any time and changes will take effect next time you start the stream.
* @param camera Can be either CameraInfo.CAMERA_FACING_BACK or CameraInfo.CAMERA_FACING_FRONT
*/
public void setCamera(int camera) {
CameraInfo cameraInfo = new CameraInfo();
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == camera) {
mCameraId = i;
break;
}
}
}
use of android.hardware.Camera.CameraInfo in project android-vision by googlesamples.
the class CameraSource method setRotation.
/**
* Calculates the correct rotation for the given camera id and sets the rotation in the
* parameters. It also sets the camera's display orientation and rotation.
*
* @param parameters the camera parameters for which to set the rotation
* @param cameraId the camera id to set rotation based on
*/
private void setRotation(Camera camera, Camera.Parameters parameters, int cameraId) {
WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
int degrees = 0;
int rotation = windowManager.getDefaultDisplay().getRotation();
switch(rotation) {
case Surface.ROTATION_0:
degrees = 0;
break;
case Surface.ROTATION_90:
degrees = 90;
break;
case Surface.ROTATION_180:
degrees = 180;
break;
case Surface.ROTATION_270:
degrees = 270;
break;
default:
Log.e(TAG, "Bad rotation value: " + rotation);
}
CameraInfo cameraInfo = new CameraInfo();
Camera.getCameraInfo(cameraId, cameraInfo);
int angle;
int displayAngle;
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
angle = (cameraInfo.orientation + degrees) % 360;
// compensate for it being mirrored
displayAngle = (360 - angle) % 360;
} else {
// back-facing
angle = (cameraInfo.orientation - degrees + 360) % 360;
displayAngle = angle;
}
// This corresponds to the rotation constants in {@link Frame}.
mRotation = angle / 90;
camera.setDisplayOrientation(displayAngle);
parameters.setRotation(angle);
}
use of android.hardware.Camera.CameraInfo in project XobotOS by xamarin.
the class CamcorderProfile method hasProfile.
/**
* Returns true if camcorder profile exists for the first back-facing
* camera at the given quality level.
* @param quality the target quality level for the camcorder profile
*/
public static boolean hasProfile(int quality) {
int 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) {
return hasProfile(i, quality);
}
}
return false;
}
use of android.hardware.Camera.CameraInfo in project android_frameworks_base by DirtyUnicorns.
the class CameraProfile method getJpegEncodingQualityParameter.
/**
* Returns a pre-defined still image capture (jpeg) quality level
* used for the given quality level in the Camera application for
* the first back-facing camera on the device. If the device has no
* back-facing camera, this returns 0.
*
* @param quality The target quality level
*/
public static int getJpegEncodingQualityParameter(int quality) {
int 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) {
return getJpegEncodingQualityParameter(i, quality);
}
}
return 0;
}
use of android.hardware.Camera.CameraInfo in project android_frameworks_base by AOSPA.
the class CamcorderProfile method get.
/**
* Returns the camcorder profile for the first back-facing camera on the
* device at the given quality level. If the device has no back-facing
* camera, this returns null.
* @param quality the target quality level for the camcorder profile
* @see #get(int, int)
*/
public static CamcorderProfile get(int quality) {
int 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) {
return get(i, quality);
}
}
return null;
}
Aggregations